finish 1.19
This commit is contained in:
+1
-1
@@ -11,4 +11,4 @@ maven_group=dev.u9g
|
|||||||
archives_base_name=minecrft-data-generator-server
|
archives_base_name=minecrft-data-generator-server
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.44.0+1.18
|
fabric_version=0.55.2+1.19
|
||||||
|
|||||||
@@ -2,23 +2,82 @@ package dev.u9g.minecraftdatagenerator.generators;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import dev.u9g.minecraftdatagenerator.mixin.TheEndBiomeDataAccessor;
|
||||||
import dev.u9g.minecraftdatagenerator.util.DGU;
|
import dev.u9g.minecraftdatagenerator.util.DGU;
|
||||||
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
|
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
|
||||||
import net.fabricmc.fabric.api.biome.v1.TheEndBiomes;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.BuiltinBiomes;
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class BiomesDataGenerator implements IDataGenerator {
|
public class BiomesDataGenerator implements IDataGenerator {
|
||||||
|
private static final Set<RegistryKey<Biome>> END_BIOMES = new HashSet<>();
|
||||||
|
|
||||||
private static String guessBiomeDimensionFromCategory(Biome biome) {
|
private static String guessBiomeDimensionFromCategory(Biome biome, String biomeName) {
|
||||||
return switch (biome.getCategory()) {
|
var key = DynamicRegistryManager.BUILTIN.get().get(Registry.BIOME_KEY).getKey(biome).orElseThrow();
|
||||||
case NETHER -> "nether";
|
if (NetherBiomes.canGenerateInNether(key)) {
|
||||||
case END -> "end";
|
return "nether";
|
||||||
default -> "overworld";
|
} else if (END_BIOMES.contains(key) || biomeName.startsWith("end_")) {
|
||||||
};
|
return "end";
|
||||||
|
}
|
||||||
|
return "overworld";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String guessCategoryBasedOnName(String name, String dimension) {
|
||||||
|
if (dimension.equals("nether")) {
|
||||||
|
return "nether";
|
||||||
|
} else if (dimension.equals("end")) {
|
||||||
|
return "the_end";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.contains("end")) {
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.contains("hills")) {
|
||||||
|
return "extreme_hills";
|
||||||
|
} else if (name.contains("ocean")) {
|
||||||
|
return "ocean";
|
||||||
|
} else if (name.contains("plains")) {
|
||||||
|
return "plains";
|
||||||
|
} else if (name.contains("ice") || name.contains("frozen")) {
|
||||||
|
return "ice";
|
||||||
|
} else if (name.contains("jungle")) {
|
||||||
|
return "jungle";
|
||||||
|
} else if (name.contains("desert")) {
|
||||||
|
return "desert";
|
||||||
|
} else if (name.contains("forest") || name.contains("grove")) {
|
||||||
|
return "forest";
|
||||||
|
} else if (name.contains("taiga")) {
|
||||||
|
return "taiga";
|
||||||
|
} else if (name.contains("swamp")) {
|
||||||
|
return "swamp";
|
||||||
|
} else if (name.contains("river")) {
|
||||||
|
return "river";
|
||||||
|
} else if (name.equals("the_end")) {
|
||||||
|
return "the_end";
|
||||||
|
} else if (name.contains("mushroom")) {
|
||||||
|
return "mushroom";
|
||||||
|
} else if (name.contains("beach") || name.equals("stony_shore")) {
|
||||||
|
return "beach";
|
||||||
|
} else if (name.contains("savanna")) {
|
||||||
|
return "savanna";
|
||||||
|
} else if (name.contains("badlands")) {
|
||||||
|
return "mesa";
|
||||||
|
} else if (name.contains("peaks") || name.equals("snowy_slopes") || name.equals("meadow")) {
|
||||||
|
return "mountain";
|
||||||
|
} else if (name.equals("the_void")) {
|
||||||
|
return "none";
|
||||||
|
} else if (name.contains("cave") || name.equals("deep_dark")) {
|
||||||
|
return "underground";
|
||||||
|
} else {
|
||||||
|
System.out.println("Unable to find biome category for biome with name: '"+name+"'");
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getBiomeColorFor(String biomeName) {
|
private static int getBiomeColorFor(String biomeName) {
|
||||||
@@ -83,22 +142,23 @@ public class BiomesDataGenerator implements IDataGenerator {
|
|||||||
else if (biomeName.equals("end_midlands")) return 15464630;
|
else if (biomeName.equals("end_midlands")) return 15464630;
|
||||||
else if (biomeName.equals("small_end_islands")) return 42;
|
else if (biomeName.equals("small_end_islands")) return 42;
|
||||||
else if (biomeName.equals("end_barrens")) return 9474162;
|
else if (biomeName.equals("end_barrens")) return 9474162;
|
||||||
else throw new Error("Unexpected biome, with name: '"+biomeName+"'");
|
System.out.println("Don't know the color of biome: '"+biomeName+"'");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||||
JsonObject biomeDesc = new JsonObject();
|
JsonObject biomeDesc = new JsonObject();
|
||||||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue();
|
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue();
|
||||||
String localizationKey = String.format("biome.%s.%s", registryKey.getNamespace(), registryKey.getPath());
|
String localizationKey = String.format("biome.%s.%s", registryKey.getNamespace(), registryKey.getPath());
|
||||||
|
String name = registryKey.getPath();
|
||||||
biomeDesc.addProperty("id", registry.getRawId(biome));
|
biomeDesc.addProperty("id", registry.getRawId(biome));
|
||||||
biomeDesc.addProperty("name", registryKey.getPath());
|
biomeDesc.addProperty("name", name);
|
||||||
|
String dimension = guessBiomeDimensionFromCategory(biome, name);
|
||||||
biomeDesc.addProperty("category", biome.getCategory().getName());
|
biomeDesc.addProperty("category", guessCategoryBasedOnName(name, dimension));
|
||||||
biomeDesc.addProperty("temperature", biome.getTemperature());
|
biomeDesc.addProperty("temperature", biome.getTemperature());
|
||||||
biomeDesc.addProperty("precipitation", biome.getPrecipitation().getName());
|
biomeDesc.addProperty("precipitation", biome.getPrecipitation().getName());
|
||||||
//biomeDesc.addProperty("depth", biome.getDepth()); - Doesn't exist anymore in minecraft source
|
//biomeDesc.addProperty("depth", biome.getDepth()); - Doesn't exist anymore in minecraft source
|
||||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
biomeDesc.addProperty("dimension", dimension);
|
||||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||||
biomeDesc.addProperty("rainfall", biome.getDownfall());
|
biomeDesc.addProperty("rainfall", biome.getDownfall());
|
||||||
@@ -114,7 +174,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public JsonArray generateDataJson() {
|
public JsonArray generateDataJson() {
|
||||||
JsonArray biomesArray = new JsonArray();
|
JsonArray biomesArray = new JsonArray();
|
||||||
DynamicRegistryManager registryManager = DynamicRegistryManager.create();
|
DynamicRegistryManager registryManager = DynamicRegistryManager.BUILTIN.get();
|
||||||
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
|
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
|
||||||
|
|
||||||
biomeRegistry.stream()
|
biomeRegistry.stream()
|
||||||
@@ -122,4 +182,10 @@ public class BiomesDataGenerator implements IDataGenerator {
|
|||||||
.forEach(biomesArray::add);
|
.forEach(biomesArray::add);
|
||||||
return biomesArray;
|
return biomesArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_BIOMES_MAP().keySet());
|
||||||
|
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_BARRENS_MAP().keySet());
|
||||||
|
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_MIDLANDS_MAP().keySet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.u9g.minecraftdatagenerator.generators;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import dev.u9g.minecraftdatagenerator.mixin.EntityTypeAccessor;
|
||||||
import dev.u9g.minecraftdatagenerator.util.DGU;
|
import dev.u9g.minecraftdatagenerator.util.DGU;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
@@ -60,7 +61,10 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
|||||||
|
|
||||||
private static String getCategoryFrom(EntityType<?> entityType) {
|
private static String getCategoryFrom(EntityType<?> entityType) {
|
||||||
if (entityType == EntityType.PLAYER) return "UNKNOWN"; // fail early for player entities
|
if (entityType == EntityType.PLAYER) return "UNKNOWN"; // fail early for player entities
|
||||||
Entity entity = EntityType.createInstanceFromId(Registry.ENTITY_TYPE.getRawId(entityType), DGU.getWorld());
|
/*public T create(World world) {
|
||||||
|
return this.factory.create(this, world);
|
||||||
|
}*/
|
||||||
|
Entity entity = ((EntityTypeAccessor)entityType).factory().create(entityType, DGU.getWorld());
|
||||||
if (entity == null) throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
if (entity == null) throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||||
entity.discard();
|
entity.discard();
|
||||||
return switch (entity.getClass().getPackageName()) {
|
return switch (entity.getClass().getPackageName()) {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class MaterialsDataGenerator implements IDataGenerator {
|
|||||||
Registry<Item> itemRegistry = Registry.ITEM;
|
Registry<Item> itemRegistry = Registry.ITEM;
|
||||||
itemRegistry.forEach(item -> {
|
itemRegistry.forEach(item -> {
|
||||||
if (item instanceof MiningToolItem toolItem) {
|
if (item instanceof MiningToolItem toolItem) {
|
||||||
Tag<Block> effectiveBlocks = ((MiningToolItemAccessor) toolItem).getEffectiveBlocks();
|
TagKey<Block> effectiveBlocks = ((MiningToolItemAccessor) toolItem).getEffectiveBlocks();
|
||||||
String materialName = makeMaterialNameForTag(effectiveBlocks);
|
String materialName = makeMaterialNameForTag(effectiveBlocks);
|
||||||
|
|
||||||
if (!uniqueMaterialNames.contains(materialName)) {
|
if (!uniqueMaterialNames.contains(materialName)) {
|
||||||
@@ -161,7 +161,7 @@ public class MaterialsDataGenerator implements IDataGenerator {
|
|||||||
itemRegistry.forEach(item -> {
|
itemRegistry.forEach(item -> {
|
||||||
//Tools are handled rather easily and do not require anything else
|
//Tools are handled rather easily and do not require anything else
|
||||||
if (item instanceof MiningToolItem toolItem) {
|
if (item instanceof MiningToolItem toolItem) {
|
||||||
Tag<Block> effectiveBlocks = ((MiningToolItemAccessor) toolItem).getEffectiveBlocks();
|
TagKey<Block> effectiveBlocks = ((MiningToolItemAccessor) toolItem).getEffectiveBlocks();
|
||||||
String materialName = makeMaterialNameForTag(effectiveBlocks);
|
String materialName = makeMaterialNameForTag(effectiveBlocks);
|
||||||
|
|
||||||
Map<Item, Float> materialSpeeds = materialMiningSpeeds.computeIfAbsent(materialName, k -> new HashMap<>());
|
Map<Item, Float> materialSpeeds = materialMiningSpeeds.computeIfAbsent(materialName, k -> new HashMap<>());
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import com.google.gson.JsonArray;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import dev.u9g.minecraftdatagenerator.mojangannoyances.BlockColors;
|
import dev.u9g.minecraftdatagenerator.mojangannoyances.BlockColors;
|
||||||
import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView;
|
import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView;
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.RedstoneWireBlock;
|
import net.minecraft.block.RedstoneWireBlock;
|
||||||
@@ -51,12 +49,10 @@ public class TintsDataGenerator implements IDataGenerator {
|
|||||||
return resultColors;
|
return resultColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
private static int getBlockColor(Block block, BlockColors blockColors) {
|
private static int getBlockColor(Block block, BlockColors blockColors) {
|
||||||
return blockColors.getColor(block.getDefaultState(), EmptyRenderBlockView.INSTANCE, BlockPos.ORIGIN, 0xFFFFFF);
|
return blockColors.getColor(block.getDefaultState(), EmptyRenderBlockView.INSTANCE, BlockPos.ORIGIN, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static Map<Block, Integer> generateConstantTintColors() {
|
public static Map<Block, Integer> generateConstantTintColors() {
|
||||||
Map<Block, Integer> resultColors = new HashMap<>();
|
Map<Block, Integer> resultColors = new HashMap<>();
|
||||||
BlockColors blockColors = BlockColors.create();
|
BlockColors blockColors = BlockColors.create();
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dev.u9g.minecraftdatagenerator.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(EntityType.class)
|
||||||
|
public interface EntityTypeAccessor<T extends Entity> {
|
||||||
|
@Accessor("factory")
|
||||||
|
public EntityType.EntityFactory<T> factory();
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package dev.u9g.minecraftdatagenerator.mixin;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
|
||||||
|
import net.fabricmc.fabric.impl.biome.WeightedPicker;
|
||||||
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@Mixin(TheEndBiomeData.class)
|
||||||
|
public interface TheEndBiomeDataAccessor {
|
||||||
|
@Accessor("END_BIOMES_MAP")
|
||||||
|
public static Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_BIOMES_MAP() {
|
||||||
|
throw new IllegalStateException("Should never be called.");
|
||||||
|
}
|
||||||
|
@Accessor("END_MIDLANDS_MAP")
|
||||||
|
public static Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_MIDLANDS_MAP() {
|
||||||
|
throw new IllegalStateException("Should never be called.");
|
||||||
|
}
|
||||||
|
@Accessor("END_BARRENS_MAP")
|
||||||
|
public static Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_BARRENS_MAP() {
|
||||||
|
throw new IllegalStateException("Should never be called.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,7 +54,7 @@ public enum EmptyRenderBlockView implements BlockRenderView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor(BlockPos pos, ColorResolver colorResolver) {
|
public int getColor(BlockPos pos, ColorResolver colorResolver) {
|
||||||
DynamicRegistryManager registryManager = DynamicRegistryManager.create();
|
DynamicRegistryManager registryManager = DynamicRegistryManager.BUILTIN.get();
|
||||||
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
|
Registry<Biome> biomeRegistry = registryManager.get(Registry.BIOME_KEY);
|
||||||
Biome plainsBiome = biomeRegistry.get(BiomeKeys.PLAINS);
|
Biome plainsBiome = biomeRegistry.get(BiomeKeys.PLAINS);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,6 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.4",
|
"fabricloader": ">=0.14.4",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.18"
|
"minecraft": "1.19"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
"package": "dev.u9g.minecraftdatagenerator.mixin",
|
"package": "dev.u9g.minecraftdatagenerator.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"ClientPlayerInteractionManagerMixin",
|
"EntityTypeAccessor",
|
||||||
"MiningToolItemAccessor",
|
"MiningToolItemAccessor",
|
||||||
"ReadyMixin"
|
"ReadyMixin",
|
||||||
|
"TheEndBiomeDataAccessor"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user