New changes (#12)

* Shutdown fast

* Change to order of releases

* Revert "Shutdown fast"

This reverts commit be2ea227718b19b00a0be0e59ec54bb87ffd5ea2.

* Remove all shutdown hook, we do not care about generator worlds

* Update README.md

* Fix typo

* Add OS-specific commands

* More code improvements

* Fix compilation

* Add job timeout

* Revert "Remove all shutdown hook, we do not care about generator worlds"

This reverts commit 44117795360c9d67fab15566e2fc6436bfe9ac6f.

* More aggressive server stopping
This commit is contained in:
Alex
2023-12-31 23:07:36 +01:00
committed by GitHub
parent 09fe9f6a2b
commit 0f1c6bdd04
117 changed files with 420 additions and 456 deletions
+4 -3
View File
@@ -9,13 +9,14 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
version: ["1.7", "1.8.9", "1.9.4", "1.10.2", "1.11.2", "1.12.2", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.19.2", "22w19a", "1.20"] version: ["1.7", "1.8.9", "1.9.4", "1.10.2", "1.11.2", "1.12.2", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "22w19a", "1.19", "1.19.2", "1.20"]
name: Build ${{ matrix.version }} name: Build ${{ matrix.version }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -7,8 +7,8 @@ import net.minecraft.world.biome.Biome;
import java.util.Iterator; import java.util.Iterator;
public class BiomeColors { public class BiomeColors {
private static final ColorProvider GRASS_COLOR = (biome, pos) -> biome.getGrassColor(pos); private static final ColorProvider GRASS_COLOR = Biome::getGrassColor;
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> biome.getFoliageColor(pos); private static final ColorProvider FOLIAGE_COLOR = Biome::getFoliageColor;
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor(); private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor();
private static int getColor(EmptyBlockView view, BlockPos pos, ColorProvider provider) { private static int getColor(EmptyBlockView view, BlockPos pos, ColorProvider provider) {
@@ -17,7 +17,7 @@ public class BiomeColors {
int k = 0; int k = 0;
int l; int l;
for (Iterator iterator = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); iterator.hasNext(); k += l & 255) { for (Iterator<BlockPos.Mutable> iterator = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); iterator.hasNext(); k += l & 255) {
BlockPos.Mutable mutable = (BlockPos.Mutable) iterator.next(); BlockPos.Mutable mutable = (BlockPos.Mutable) iterator.next();
l = provider.getColorAtPos(view.getBiome(mutable), mutable); l = provider.getColorAtPos(view.getBiome(mutable), mutable);
i += (l & 16711680) >> 16; i += (l & 16711680) >> 16;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.*; import net.minecraft.block.*;
@@ -19,7 +19,7 @@ public class BlockColors {
public static BlockColors create() { public static BlockColors create() {
final BlockColors blockColors = new BlockColors(); final BlockColors blockColors = new BlockColors();
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
DoublePlantBlock.DoublePlantType doublePlantType = (DoublePlantBlock.DoublePlantType) blockState.get(DoublePlantBlock.VARIANT); DoublePlantBlock.DoublePlantType doublePlantType = blockState.get(DoublePlantBlock.VARIANT);
return blockView == null || blockPos == null || doublePlantType != DoublePlantBlock.DoublePlantType.GRASS && doublePlantType != DoublePlantBlock.DoublePlantType.FERN ? -1 : BiomeColors.getGrassColor(blockView, blockPos); return blockView == null || blockPos == null || doublePlantType != DoublePlantBlock.DoublePlantType.GRASS && doublePlantType != DoublePlantBlock.DoublePlantType.FERN ? -1 : BiomeColors.getGrassColor(blockView, blockPos);
}, Blocks.DOUBLE_PLANT); }, Blocks.DOUBLE_PLANT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
@@ -38,7 +38,7 @@ public class BlockColors {
}, Blocks.FLOWER_POT); }, Blocks.FLOWER_POT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : GrassColors.getColor(0.5D, 1.0D), Blocks.GRASS); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : GrassColors.getColor(0.5D, 1.0D), Blocks.GRASS);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
PlanksBlock.WoodType woodType = (PlanksBlock.WoodType) blockState.get(Leaves1Block.VARIANT); PlanksBlock.WoodType woodType = blockState.get(Leaves1Block.VARIANT);
if (woodType == PlanksBlock.WoodType.SPRUCE) { if (woodType == PlanksBlock.WoodType.SPRUCE) {
return FoliageColors.getSpruceColor(); return FoliageColors.getSpruceColor();
} else if (woodType == PlanksBlock.WoodType.BIRCH) { } else if (woodType == PlanksBlock.WoodType.BIRCH) {
@@ -49,10 +49,10 @@ public class BlockColors {
}, Blocks.LEAVES); }, Blocks.LEAVES);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER);
blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877((Integer) blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877(blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
int j = (Integer) blockState.get(AttachedStemBlock.AGE); int j = blockState.get(AttachedStemBlock.AGE);
int k = j * 32; int k = j * 32;
int l = 255 - j * 8; int l = 255 - j * 8;
int m = j * 4; int m = j * 4;
@@ -71,9 +71,9 @@ public class BlockColors {
} }
public int method_13410(BlockState blockState) { public int method_13410(BlockState blockState) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock())); BlockColorable blockColorable = this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
if (blockColorable != null) { if (blockColorable != null) {
return blockColorable.method_12155(blockState, (EmptyBlockView) null, (BlockPos) null, 0); return blockColorable.method_12155(blockState, null, null, 0);
} else { } else {
MaterialColor materialColor = blockState.getMaterialColor(); MaterialColor materialColor = blockState.getMaterialColor();
return materialColor != null ? materialColor.color : -1; return materialColor != null ? materialColor.color : -1;
@@ -81,15 +81,14 @@ public class BlockColors {
} }
public int method_12157(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i) { public int method_12157(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock())); BlockColorable blockColorable = this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
return blockColorable == null ? -1 : blockColorable.method_12155(blockState, blockView, blockPos, i); return blockColorable == null ? -1 : blockColorable.method_12155(blockState, blockView, blockPos, i);
} }
public void method_12158(BlockColorable blockColorable, Block... blocks) { public void method_12158(BlockColorable blockColorable, Block... blocks) {
int i = blocks.length; int i = blocks.length;
for (int j = 0; j < i; ++j) { for (Block block : blocks) {
Block block = blocks[j];
this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block)); this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block));
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -30,8 +30,8 @@ public class FoliageColors {
} }
public static int getFoliageColor(Biome biome) { public static int getFoliageColor(Biome biome) {
double d = (double) MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F); double d = MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F); double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return FoliageColors.getColor(d, e); return FoliageColors.getColor(d, e);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -19,8 +19,8 @@ public class GrassColors {
} }
public static int getGrassColor(Biome biome) { public static int getGrassColor(Biome biome) {
double d = (double) MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F); double d = MathHelper.clamp(biome.getTemperature(), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F); double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return GrassColors.getColor(d, e); return GrassColors.getColor(d, e);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -96,12 +96,7 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return shapes; return shapes;
} }
private static class Shapes { private record Shapes(List<Box> boxes) {
final List<Box> boxes;
public Shapes(List<Box> boxes) {
this.boxes = boxes;
}
public JsonArray toJSON() { public JsonArray toJSON() {
JsonArray arr = new JsonArray(); JsonArray arr = new JsonArray();
@@ -117,10 +112,6 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return Objects.equals(boxes, shapes.boxes); return Objects.equals(boxes, shapes.boxes);
} }
@Override
public int hashCode() {
return boxes != null ? boxes.hashCode() : 0;
}
} }
} }
} }
@@ -45,16 +45,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -65,16 +65,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -55,7 +55,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
private static String getCategoryFrom(@NotNull Class<?> entityClass) { private static String getCategoryFrom(@NotNull Class<?> entityClass) {
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
String packageName = entityClass.getPackage().getName(); String packageName = entityClass.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -65,7 +65,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -3,10 +3,10 @@ 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 com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import dev.u9g.minecraftdatagenerator.util.Registries; import dev.u9g.minecraftdatagenerator.util.Registries;
@@ -16,12 +16,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
System.exit(0); Runtime.getRuntime().halt(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -9,13 +9,13 @@ import java.util.Iterator;
public class BiomeColors { public class BiomeColors {
private static final ColorProvider GRASS_COLOR = (biome, pos) -> { private static final ColorProvider GRASS_COLOR = (biome, pos) -> {
double d = (double) MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F); double d = MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F); double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return GrassColors.getColor(d, e); return GrassColors.getColor(d, e);
}; };
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> { private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> {
double d = (double) MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F); double d = MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F); double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
return FoliageColors.getColor(d, e); return FoliageColors.getColor(d, e);
}; };
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor(); private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor();
@@ -26,7 +26,7 @@ public class BiomeColors {
int k = 0; int k = 0;
int l; int l;
for (Iterator var6 = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); var6.hasNext(); k += l & 255) { for (Iterator<BlockPos.Mutable> var6 = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); var6.hasNext(); k += l & 255) {
BlockPos.Mutable mutable = (BlockPos.Mutable) var6.next(); BlockPos.Mutable mutable = (BlockPos.Mutable) var6.next();
l = provider.getColorAtPos(view.getBiome(mutable), mutable); l = provider.getColorAtPos(view.getBiome(mutable), mutable);
i += (l & 16711680) >> 16; i += (l & 16711680) >> 16;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.*; import net.minecraft.block.*;
@@ -18,7 +18,7 @@ public class BlockColors {
public static BlockColors create() { public static BlockColors create() {
final BlockColors blockColors = new BlockColors(); final BlockColors blockColors = new BlockColors();
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
DoublePlantBlock.DoublePlantType doublePlantType = (DoublePlantBlock.DoublePlantType) blockState.get(DoublePlantBlock.VARIANT); DoublePlantBlock.DoublePlantType doublePlantType = blockState.get(DoublePlantBlock.VARIANT);
return blockView != null && blockPos != null && (doublePlantType == DoublePlantBlock.DoublePlantType.GRASS || doublePlantType == DoublePlantBlock.DoublePlantType.FERN) ? BiomeColors.getGrassColor(blockView, blockState.get(DoublePlantBlock.HALF) == DoublePlantBlock.HalfType.UPPER ? blockPos.down() : blockPos) : -1; return blockView != null && blockPos != null && (doublePlantType == DoublePlantBlock.DoublePlantType.GRASS || doublePlantType == DoublePlantBlock.DoublePlantType.FERN) ? BiomeColors.getGrassColor(blockView, blockState.get(DoublePlantBlock.HALF) == DoublePlantBlock.HalfType.UPPER ? blockPos.down() : blockPos) : -1;
}, Blocks.DOUBLE_PLANT); }, Blocks.DOUBLE_PLANT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
@@ -37,7 +37,7 @@ public class BlockColors {
}, Blocks.FLOWER_POT); }, Blocks.FLOWER_POT);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : GrassColors.getColor(0.5D, 1.0D), Blocks.GRASS); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : GrassColors.getColor(0.5D, 1.0D), Blocks.GRASS);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
PlanksBlock.WoodType woodType = (PlanksBlock.WoodType) blockState.get(Leaves1Block.VARIANT); PlanksBlock.WoodType woodType = blockState.get(Leaves1Block.VARIANT);
if (woodType == PlanksBlock.WoodType.SPRUCE) { if (woodType == PlanksBlock.WoodType.SPRUCE) {
return net.minecraft.client.color.world.FoliageColors.getSpruceColor(); return net.minecraft.client.color.world.FoliageColors.getSpruceColor();
} else if (woodType == PlanksBlock.WoodType.BIRCH) { } else if (woodType == PlanksBlock.WoodType.BIRCH) {
@@ -48,10 +48,10 @@ public class BlockColors {
}, Blocks.LEAVES); }, Blocks.LEAVES);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER);
blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877((Integer) blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877(blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
int j = (Integer) blockState.get(AttachedStemBlock.AGE); int j = blockState.get(AttachedStemBlock.AGE);
int k = j * 32; int k = j * 32;
int l = 255 - j * 8; int l = 255 - j * 8;
int m = j * 4; int m = j * 4;
@@ -70,9 +70,9 @@ public class BlockColors {
} }
public int method_13410(BlockState blockState) { public int method_13410(BlockState blockState) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock())); BlockColorable blockColorable = this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
if (blockColorable != null) { if (blockColorable != null) {
return blockColorable.method_12155(blockState, null, (BlockPos) null, 0); return blockColorable.method_12155(blockState, null, null, 0);
} else { } else {
MaterialColor materialColor = blockState.getMaterialColor(); MaterialColor materialColor = blockState.getMaterialColor();
return materialColor != null ? materialColor.color : -1; return materialColor != null ? materialColor.color : -1;
@@ -80,15 +80,14 @@ public class BlockColors {
} }
public int method_12157(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i) { public int method_12157(BlockState blockState, @Nullable EmptyBlockView blockView, @Nullable BlockPos blockPos, int i) {
BlockColorable blockColorable = (BlockColorable) this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock())); BlockColorable blockColorable = this.BlockColor2Id.fromId(Block.getIdByBlock(blockState.getBlock()));
return blockColorable == null ? -1 : blockColorable.method_12155(blockState, blockView, blockPos, i); return blockColorable == null ? -1 : blockColorable.method_12155(blockState, blockView, blockPos, i);
} }
public void method_12158(BlockColorable blockColorable, Block... blocks) { public void method_12158(BlockColorable blockColorable, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block)); this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block));
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
public class FoliageColors { public class FoliageColors {
private static int[] colorMap = new int[65536]; private static int[] colorMap = new int[65536];
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
public class GrassColors { public class GrassColors {
private static int[] colorMap = new int[65536]; private static int[] colorMap = new int[65536];
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -2,7 +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.ClientSideAnnoyances.SkyColor; import dev.u9g.minecraftdatagenerator.clientsideannoyances.SkyColor;
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.SimpleRegistry; import net.minecraft.util.registry.SimpleRegistry;
@@ -93,12 +93,7 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return shapes; return shapes;
} }
private static class Shapes { private record Shapes(List<Box> boxes) {
final List<Box> boxes;
public Shapes(List<Box> boxes) {
this.boxes = boxes;
}
public JsonArray toJSON() { public JsonArray toJSON() {
JsonArray arr = new JsonArray(); JsonArray arr = new JsonArray();
@@ -114,10 +109,6 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return Objects.equals(boxes, shapes.boxes); return Objects.equals(boxes, shapes.boxes);
} }
@Override
public int hashCode() {
return boxes != null ? boxes.hashCode() : 0;
}
} }
} }
} }
@@ -45,16 +45,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -65,16 +65,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -49,7 +49,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
private static String getCategoryFrom(@NotNull Class<?> entityClass) { private static String getCategoryFrom(@NotNull Class<?> entityClass) {
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
String packageName = entityClass.getPackage().getName(); String packageName = entityClass.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -59,7 +59,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -3,9 +3,9 @@ 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 com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BiomeColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BiomeColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import dev.u9g.minecraftdatagenerator.util.Registries; import dev.u9g.minecraftdatagenerator.util.Registries;
@@ -16,12 +16,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
System.exit(0); Runtime.getRuntime().halt(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@@ -7,8 +7,8 @@ import net.minecraft.world.biome.Biome;
import java.util.Iterator; import java.util.Iterator;
public class BiomeColors { public class BiomeColors {
private static final ColorProvider GRASS_COLOR = (biome, pos) -> biome.getGrassColor(pos); private static final ColorProvider GRASS_COLOR = Biome::getGrassColor;
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> biome.getFoliageColor(pos); private static final ColorProvider FOLIAGE_COLOR = Biome::getFoliageColor;
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor(); private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor();
private static int getColor(BlockView view, BlockPos pos, ColorProvider provider) { private static int getColor(BlockView view, BlockPos pos, ColorProvider provider) {
@@ -18,7 +18,7 @@ public class BiomeColors {
int l; int l;
for (Iterator<BlockPos.Mutable> var6 = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); var6.hasNext(); k += l & 255) { for (Iterator<BlockPos.Mutable> var6 = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); var6.hasNext(); k += l & 255) {
BlockPos.Mutable mutable = (BlockPos.Mutable) var6.next(); BlockPos.Mutable mutable = var6.next();
l = provider.getColorAtPos(view.getBiome(mutable), mutable); l = provider.getColorAtPos(view.getBiome(mutable), mutable);
i += (l & 16711680) >> 16; i += (l & 16711680) >> 16;
j += (l & '\uff00') >> 8; j += (l & '\uff00') >> 8;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@@ -51,7 +51,7 @@ public class BlockColors {
}, Blocks.LEAVES); }, Blocks.LEAVES);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getFoliageColor(blockView, blockPos) : FoliageColors.getDefaultColor(), Blocks.LEAVES2);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getWaterColor(blockView, blockPos) : -1, Blocks.WATER, Blocks.FLOWING_WATER);
blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877((Integer) blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.method_12158((blockState, blockView, blockPos, i) -> RedstoneWireBlock.method_8877(blockState.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE); blockColors.method_12158((blockState, blockView, blockPos, i) -> blockView != null && blockPos != null ? BiomeColors.getGrassColor(blockView, blockPos) : -1, Blocks.SUGARCANE);
blockColors.method_12158((blockState, blockView, blockPos, i) -> { blockColors.method_12158((blockState, blockView, blockPos, i) -> {
int j = blockState.get(AttachedStemBlock.AGE); int j = blockState.get(AttachedStemBlock.AGE);
@@ -91,8 +91,7 @@ public class BlockColors {
public void method_12158(BlockColorable blockColorable, Block... blocks) { public void method_12158(BlockColorable blockColorable, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block)); this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block));
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -95,12 +95,7 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return shapes; return shapes;
} }
private static class Shapes { private record Shapes(List<Box> boxes) {
final List<Box> boxes;
public Shapes(List<Box> boxes) {
this.boxes = boxes;
}
public JsonArray toJSON() { public JsonArray toJSON() {
JsonArray arr = new JsonArray(); JsonArray arr = new JsonArray();
@@ -116,10 +111,6 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return Objects.equals(boxes, shapes.boxes); return Objects.equals(boxes, shapes.boxes);
} }
@Override
public int hashCode() {
return boxes != null ? boxes.hashCode() : 0;
}
} }
} }
} }
@@ -45,16 +45,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -65,16 +65,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -55,7 +55,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
private static String getCategoryFrom(@NotNull Class<?> entityClass) { private static String getCategoryFrom(@NotNull Class<?> entityClass) {
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
String packageName = entityClass.getPackage().getName(); String packageName = entityClass.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -65,7 +65,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -2,10 +2,10 @@ 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.ClientSideAnnoyances.BlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
import dev.u9g.minecraftdatagenerator.util.DGU; import dev.u9g.minecraftdatagenerator.util.DGU;
import dev.u9g.minecraftdatagenerator.util.Registries; import dev.u9g.minecraftdatagenerator.util.Registries;
@@ -16,13 +16,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stopServer(); Runtime.getRuntime().halt(0);
System.exit(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.class_2181; import net.minecraft.class_2181;
@@ -56,8 +56,7 @@ public class BlockColors {
public void method_12158(BlockColorable blockColorable, Block... blocks) { public void method_12158(BlockColorable blockColorable, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.BlockColor2Id.set(blockColorable, Registry.BLOCK.getRawId(block)); this.BlockColor2Id.set(blockColorable, Registry.BLOCK.getRawId(block));
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -13,12 +13,11 @@ import java.util.Objects;
public class BiomesDataGenerator implements IDataGenerator { public class BiomesDataGenerator implements IDataGenerator {
private static String guessBiomeDimensionFromCategory(Biome biome) { private static String guessBiomeDimensionFromCategory(Biome biome) {
String category = switch (biome.getCategory()) { return switch (biome.getCategory()) {
case NETHER -> "nether"; case NETHER -> "nether";
case THEEND -> "end"; case THEEND -> "end";
default -> "overworld"; default -> "overworld";
}; };
return category;
} }
private static int getBiomeColorFor(String biomeName) { private static int getBiomeColorFor(String biomeName) {
@@ -44,16 +44,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -64,16 +64,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -77,7 +77,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
if (entityType == EntityType.PLAYER) return "other"; // fail early for player entities if (entityType == EntityType.PLAYER) return "other"; // fail early for player entities
Class<? extends Entity> entityClazz = getEntityClass(entityType); Class<? extends Entity> entityClazz = getEntityClass(entityType);
String packageName = entityClazz.getPackage().getName(); String packageName = entityClazz.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -87,7 +87,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -2,10 +2,10 @@ 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.ClientSideAnnoyances.BlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.util.DGU; import dev.u9g.minecraftdatagenerator.util.DGU;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@@ -16,13 +16,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stopServer(); Runtime.getRuntime().halt(0);
System.exit(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -44,16 +44,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -64,16 +64,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -2,9 +2,9 @@ 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.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.util.DGU; import dev.u9g.minecraftdatagenerator.util.DGU;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
@@ -17,12 +17,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = MinecraftVersion.create().getName(); String versionName = MinecraftVersion.create().getName();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.client.util.math.Vector3f; import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -44,16 +44,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -64,16 +64,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -2,9 +2,9 @@ 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.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@@ -17,12 +17,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = MinecraftVersion.create().getName(); String versionName = MinecraftVersion.create().getName();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.client.util.math.Vector3f; import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -44,16 +44,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -64,16 +64,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -75,7 +75,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -2,9 +2,9 @@ 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.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.mixin.BiomeEffectsAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeEffectsAccessor;
import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyRenderBlockView;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
@@ -17,12 +17,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = MinecraftVersion.field_25319.getName(); String versionName = MinecraftVersion.field_25319.getName();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -75,7 +75,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -22,6 +22,6 @@ public class ReadyMixin {
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.info("Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -75,7 +75,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -22,6 +22,6 @@ public class ReadyMixin {
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.info("Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -75,7 +75,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -22,6 +22,6 @@ public class ReadyMixin {
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.info("Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -34,12 +34,12 @@ public class BlockColors {
blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor((Integer) state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor(state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE); blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM); blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> { blockColors.registerColorProvider((state, world, pos, tintIndex) -> {
int i = (Integer) state.get(StemBlock.AGE); int i = state.get(StemBlock.AGE);
int j = i * 32; int j = i * 32;
int k = 255 - i * 8; int k = 255 - i * 8;
int l = i * 4; int l = i * 4;
@@ -51,9 +51,9 @@ public class BlockColors {
} }
public int getParticleColor(BlockState state, World world, BlockPos pos) { public int getParticleColor(BlockState state, World world, BlockPos pos) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(Registry.BLOCK.getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(Registry.BLOCK.getRawId(state.getBlock()));
if (blockColorProvider != null) { if (blockColorProvider != null) {
return blockColorProvider.getColor(state, (BlockRenderView) null, (BlockPos) null, 0); return blockColorProvider.getColor(state, null, null, 0);
} else { } else {
MapColor mapColor = state.getMapColor(world, pos); MapColor mapColor = state.getMapColor(world, pos);
return mapColor != null ? mapColor.color : -1; return mapColor != null ? mapColor.color : -1;
@@ -61,15 +61,14 @@ public class BlockColors {
} }
public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) { public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(Registry.BLOCK.getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(Registry.BLOCK.getRawId(state.getBlock()));
return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex); return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex);
} }
public void registerColorProvider(BlockColorProvider provider, Block... blocks) { public void registerColorProvider(BlockColorProvider provider, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.providers.set(provider, Registry.BLOCK.getRawId(block)); this.providers.set(provider, Registry.BLOCK.getRawId(block));
} }
@@ -78,8 +77,7 @@ public class BlockColors {
private void registerColorProperties(Set<Property<?>> properties, Block... blocks) { private void registerColorProperties(Set<Property<?>> properties, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.properties.put(block, properties); this.properties.put(block, properties);
} }
@@ -90,6 +88,6 @@ public class BlockColors {
} }
public Set<Property<?>> getProperties(Block block) { public Set<Property<?>> getProperties(Block block) {
return (Set) this.properties.getOrDefault(block, ImmutableSet.of()); return this.properties.getOrDefault(block, ImmutableSet.of());
} }
} }
@@ -75,7 +75,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -22,6 +22,6 @@ public class ReadyMixin {
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.info("Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -34,12 +34,12 @@ public class BlockColors {
blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor((Integer) state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor(state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE); blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM); blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> { blockColors.registerColorProvider((state, world, pos, tintIndex) -> {
int i = (Integer) state.get(StemBlock.AGE); int i = state.get(StemBlock.AGE);
int j = i * 32; int j = i * 32;
int k = 255 - i * 8; int k = 255 - i * 8;
int l = i * 4; int l = i * 4;
@@ -51,9 +51,9 @@ public class BlockColors {
} }
public int getParticleColor(BlockState state, World world, BlockPos pos) { public int getParticleColor(BlockState state, World world, BlockPos pos) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(Registry.BLOCK.getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(Registry.BLOCK.getRawId(state.getBlock()));
if (blockColorProvider != null) { if (blockColorProvider != null) {
return blockColorProvider.getColor(state, (BlockRenderView) null, (BlockPos) null, 0); return blockColorProvider.getColor(state, null, null, 0);
} else { } else {
MapColor mapColor = state.getMapColor(world, pos); MapColor mapColor = state.getMapColor(world, pos);
return mapColor != null ? mapColor.color : -1; return mapColor != null ? mapColor.color : -1;
@@ -61,15 +61,14 @@ public class BlockColors {
} }
public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) { public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(Registry.BLOCK.getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(Registry.BLOCK.getRawId(state.getBlock()));
return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex); return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex);
} }
public void registerColorProvider(BlockColorProvider provider, Block... blocks) { public void registerColorProvider(BlockColorProvider provider, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.providers.set(provider, Registry.BLOCK.getRawId(block)); this.providers.set(provider, Registry.BLOCK.getRawId(block));
} }
@@ -78,8 +77,7 @@ public class BlockColors {
private void registerColorProperties(Set<Property<?>> properties, Block... blocks) { private void registerColorProperties(Set<Property<?>> properties, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.properties.put(block, properties); this.properties.put(block, properties);
} }
@@ -90,6 +88,6 @@ public class BlockColors {
} }
public Set<Property<?>> getProperties(Block block) { public Set<Property<?>> getProperties(Block block) {
return (Set) this.properties.getOrDefault(block, ImmutableSet.of()); return this.properties.getOrDefault(block, ImmutableSet.of());
} }
} }
@@ -76,7 +76,7 @@ public class EnchantmentsDataGenerator implements IDataGenerator {
List<Enchantment> incompatibleEnchantments = registry.stream() List<Enchantment> incompatibleEnchantments = registry.stream()
.filter(other -> !enchantment.canCombine(other)) .filter(other -> !enchantment.canCombine(other))
.filter(other -> other != enchantment) .filter(other -> other != enchantment)
.collect(Collectors.toList()); .toList();
JsonArray excludes = new JsonArray(); JsonArray excludes = new JsonArray();
for (Enchantment excludedEnchantment : incompatibleEnchantments) { for (Enchantment excludedEnchantment : incompatibleEnchantments) {
@@ -22,6 +22,6 @@ public class ReadyMixin {
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.info("Done data generation!"); Main.LOGGER.info("Done data generation!");
DGU.getCurrentlyRunningServer().stop(false); Runtime.getRuntime().halt(0);
} }
} }
@@ -35,12 +35,12 @@ public class BlockColors {
blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> FoliageColors.getBirchColor(), Blocks.BIRCH_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getFoliageColor(world, pos) : FoliageColors.getDefaultColor(), Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getWaterColor(world, pos) : -1, Blocks.WATER, Blocks.BUBBLE_COLUMN, Blocks.WATER_CAULDRON);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor((Integer) state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> RedstoneWireBlock.getWireColor(state.get(RedstoneWireBlock.POWER)), Blocks.REDSTONE_WIRE);
blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE); blockColors.registerColorProperty(RedstoneWireBlock.POWER, Blocks.REDSTONE_WIRE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE); blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? BiomeColors.getGrassColor(world, pos) : -1, Blocks.SUGAR_CANE);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM); blockColors.registerColorProvider((state, world, pos, tintIndex) -> 14731036, Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM);
blockColors.registerColorProvider((state, world, pos, tintIndex) -> { blockColors.registerColorProvider((state, world, pos, tintIndex) -> {
int i = (Integer) state.get(StemBlock.AGE); int i = state.get(StemBlock.AGE);
int j = i * 32; int j = i * 32;
int k = 255 - i * 8; int k = 255 - i * 8;
int l = i * 4; int l = i * 4;
@@ -52,9 +52,9 @@ public class BlockColors {
} }
public int getParticleColor(BlockState state, World world, BlockPos pos) { public int getParticleColor(BlockState state, World world, BlockPos pos) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(state.getBlock()));
if (blockColorProvider != null) { if (blockColorProvider != null) {
return blockColorProvider.getColor(state, (BlockRenderView) null, (BlockPos) null, 0); return blockColorProvider.getColor(state, null, null, 0);
} else { } else {
MapColor mapColor = state.getMapColor(world, pos); MapColor mapColor = state.getMapColor(world, pos);
return mapColor != null ? mapColor.color : -1; return mapColor != null ? mapColor.color : -1;
@@ -62,15 +62,14 @@ public class BlockColors {
} }
public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) { public int getColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tintIndex) {
BlockColorProvider blockColorProvider = (BlockColorProvider) this.providers.get(DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(state.getBlock())); BlockColorProvider blockColorProvider = this.providers.get(DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(state.getBlock()));
return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex); return blockColorProvider == null ? -1 : blockColorProvider.getColor(state, world, pos, tintIndex);
} }
public void registerColorProvider(BlockColorProvider provider, Block... blocks) { public void registerColorProvider(BlockColorProvider provider, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.providers.set(provider, DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(block)); this.providers.set(provider, DGU.getWorld().getRegistryManager().get(RegistryKeys.BLOCK).getRawId(block));
} }
@@ -79,8 +78,7 @@ public class BlockColors {
private void registerColorProperties(Set<Property<?>> properties, Block... blocks) { private void registerColorProperties(Set<Property<?>> properties, Block... blocks) {
int var4 = blocks.length; int var4 = blocks.length;
for (int var5 = 0; var5 < var4; ++var5) { for (Block block : blocks) {
Block block = blocks[var5];
this.properties.put(block, properties); this.properties.put(block, properties);
} }
@@ -91,6 +89,6 @@ public class BlockColors {
} }
public Set<Property<?>> getProperties(Block block) { public Set<Property<?>> getProperties(Block block) {
return (Set) this.properties.getOrDefault(block, ImmutableSet.of()); return this.properties.getOrDefault(block, ImmutableSet.of());
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -111,12 +111,7 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return shapes; return shapes;
} }
private static class Shapes { private record Shapes(List<Box> boxes) {
final List<Box> boxes;
public Shapes(List<Box> boxes) {
this.boxes = boxes;
}
public JsonArray toJSON() { public JsonArray toJSON() {
JsonArray arr = new JsonArray(); JsonArray arr = new JsonArray();
@@ -132,10 +127,6 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return Objects.equals(boxes, shapes.boxes); return Objects.equals(boxes, shapes.boxes);
} }
@Override
public int hashCode() {
return boxes != null ? boxes.hashCode() : 0;
}
} }
} }
} }
@@ -45,16 +45,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -65,16 +65,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -54,7 +54,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
private static String getCategoryFrom(@NotNull Class<?> entityClass) { private static String getCategoryFrom(@NotNull Class<?> entityClass) {
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
String packageName = entityClass.getPackage().getName(); String packageName = entityClass.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -64,7 +64,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -3,9 +3,9 @@ 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 com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BiomeBlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BiomeBlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.mixin.accessor.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.accessor.BiomeAccessor;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import dev.u9g.minecraftdatagenerator.util.Registries; import dev.u9g.minecraftdatagenerator.util.Registries;
@@ -19,12 +19,12 @@ public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Registries.init(); Registries.init();
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = (new File(".")).toPath().toAbsolutePath(); Path serverRootDirectory = (new File(".")).toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
System.exit(0); Runtime.getRuntime().halt(0);
} }
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import net.minecraft.block.*; import net.minecraft.block.*;
@@ -46,7 +46,7 @@ public class BiomeBlockColors {
} else if (block instanceof SugarCaneBlock || block instanceof TallPlantBlock) { } else if (block instanceof SugarCaneBlock || block instanceof TallPlantBlock) {
return GrassColors.getGrassColor(EmptyBlockView.INSTANCE.getBiome(BlockPos.ORIGIN)); return GrassColors.getGrassColor(EmptyBlockView.INSTANCE.getBiome(BlockPos.ORIGIN));
} else if (block instanceof VineBlock) { } else if (block instanceof VineBlock) {
return dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors.getFoliageColor(EmptyBlockView.INSTANCE.getBiome(BlockPos.ORIGIN)); return dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors.getFoliageColor(EmptyBlockView.INSTANCE.getBiome(BlockPos.ORIGIN));
} }
return 0xFFFFFF; return 0xFFFFFF;
} }
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@@ -7,8 +7,8 @@ import net.minecraft.world.biome.Biome;
import java.util.Iterator; import java.util.Iterator;
public class BiomeColors { public class BiomeColors {
private static final ColorProvider GRASS_COLOR = (biome, pos) -> biome.getGrassColor(pos); private static final ColorProvider GRASS_COLOR = Biome::getGrassColor;
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> biome.getFoliageColor(pos); private static final ColorProvider FOLIAGE_COLOR = Biome::getFoliageColor;
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.waterColor; private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.waterColor;
private static int getColor(BlockView view, BlockPos pos, ColorProvider provider) { private static int getColor(BlockView view, BlockPos pos, ColorProvider provider) {
@@ -17,7 +17,7 @@ public class BiomeColors {
int k = 0; int k = 0;
int l; int l;
for (Iterator iterator = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); iterator.hasNext(); k += l & 255) { for (Iterator<BlockPos.Mutable> iterator = BlockPos.mutableIterate(pos.add(-1, 0, -1), pos.add(1, 0, 1)).iterator(); iterator.hasNext(); k += l & 255) {
BlockPos.Mutable mutable = (BlockPos.Mutable) iterator.next(); BlockPos.Mutable mutable = (BlockPos.Mutable) iterator.next();
l = provider.getColorAtPos(view.getBiome(mutable), mutable); l = provider.getColorAtPos(view.getBiome(mutable), mutable);
i += (l & 16711680) >> 16; i += (l & 16711680) >> 16;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@@ -1,4 +1,4 @@
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances; package dev.u9g.minecraftdatagenerator.clientsideannoyances;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -96,12 +96,7 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return shapes; return shapes;
} }
private static class Shapes { private record Shapes(List<Box> boxes) {
final List<Box> boxes;
public Shapes(List<Box> boxes) {
this.boxes = boxes;
}
public JsonArray toJSON() { public JsonArray toJSON() {
JsonArray arr = new JsonArray(); JsonArray arr = new JsonArray();
@@ -117,10 +112,6 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
return Objects.equals(boxes, shapes.boxes); return Objects.equals(boxes, shapes.boxes);
} }
@Override
public int hashCode() {
return boxes != null ? boxes.hashCode() : 0;
}
} }
} }
} }
@@ -45,16 +45,16 @@ public class DataGenerators {
try { try {
Files.createDirectories(outputDirectory); Files.createDirectories(outputDirectory);
} catch (IOException exception) { } catch (IOException exception) {
logger.log(Level.INFO, "Failed to create data generator output directory at " + outputDirectory); logger.info("Failed to create data generator output directory at " + outputDirectory);
exception.printStackTrace(); exception.printStackTrace();
return false; return false;
} }
int generatorsFailed = 0; int generatorsFailed = 0;
logger.log(Level.INFO, MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory)); logger.info(MessageFormat.format("Running minecraft data generators, output at {0}", outputDirectory));
for (IDataGenerator dataGenerator : GENERATORS) { for (IDataGenerator dataGenerator : GENERATORS) {
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
try { try {
String outputFileName = String.format("%s.json", dataGenerator.getDataName()); String outputFileName = String.format("%s.json", dataGenerator.getDataName());
JsonElement outputElement = dataGenerator.generateDataJson(); JsonElement outputElement = dataGenerator.generateDataJson();
@@ -65,16 +65,16 @@ public class DataGenerators {
jsonWriter.setIndent(" "); jsonWriter.setIndent(" ");
Streams.write(outputElement, jsonWriter); Streams.write(outputElement, jsonWriter);
} }
logger.log(Level.INFO, MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName)); logger.info(MessageFormat.format("Generator: {0} -> {1}", dataGenerator.getDataName(), outputFileName));
} catch (Throwable exception) { } catch (Throwable exception) {
logger.log(Level.INFO, MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName())); logger.info(MessageFormat.format("Failed to run data generator {0}", dataGenerator.getDataName()));
exception.printStackTrace(); exception.printStackTrace();
generatorsFailed++; generatorsFailed++;
} }
} }
logger.log(Level.INFO, "Finishing running data generators"); logger.info("Finishing running data generators");
return generatorsFailed == 0; return generatorsFailed == 0;
} }
} }
@@ -55,7 +55,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
private static String getCategoryFrom(@NotNull Class<?> entityClass) { private static String getCategoryFrom(@NotNull Class<?> entityClass) {
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
String packageName = entityClass.getPackage().getName(); String packageName = entityClass.getPackage().getName();
String category = switch (packageName) { return switch (packageName) {
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile"; case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" -> case "net.minecraft.entity.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
"Hostile mobs"; "Hostile mobs";
@@ -65,7 +65,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
case "net.minecraft.entity" -> "other"; case "net.minecraft.entity" -> "other";
default -> throw new Error("Unexpected entity type: " + packageName); default -> throw new Error("Unexpected entity type: " + packageName);
}; };
return category;
} }
//Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information //Honestly, both "type" and "category" fields in the schema and examples do not contain any useful information
@@ -3,10 +3,10 @@ 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 com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BiomeBlockColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.BiomeBlockColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.FoliageColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.FoliageColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.GrassColors; import dev.u9g.minecraftdatagenerator.clientsideannoyances.GrassColors;
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock; import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor; import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView; import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
import dev.u9g.minecraftdatagenerator.util.Registries; import dev.u9g.minecraftdatagenerator.util.Registries;
@@ -16,12 +16,12 @@ import java.util.logging.Level;
public class ReadyMixin { public class ReadyMixin {
@Inject(method = "setupServer()Z", at = @At("TAIL")) @Inject(method = "setupServer()Z", at = @At("TAIL"))
private void init(CallbackInfoReturnable<Boolean> cir) { private void init(CallbackInfoReturnable<Boolean> cir) {
Main.LOGGER.log(Level.INFO, "Starting data generation!"); Main.LOGGER.info("Starting data generation!");
String versionName = DGU.getCurrentlyRunningServer().getVersion(); String versionName = DGU.getCurrentlyRunningServer().getVersion();
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath(); Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName); Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
DataGenerators.runDataGenerators(dataDumpDirectory); DataGenerators.runDataGenerators(dataDumpDirectory);
Main.LOGGER.log(Level.INFO, "Done data generation!"); Main.LOGGER.info("Done data generation!");
System.exit(0); Runtime.getRuntime().halt(0);
} }
} }
@@ -8,9 +8,11 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Unique;
@Mixin(CocoaBlock.class) @Mixin(CocoaBlock.class)
public class CocoaBlockOverwrite { public class CocoaBlockOverwrite {
@Unique
private static Box collisionBox(BlockState state) { private static Box collisionBox(BlockState state) {
Direction direction = state.get(CocoaBlock.FACING); Direction direction = state.get(CocoaBlock.FACING);
int i = state.get(CocoaBlock.AGE); int i = state.get(CocoaBlock.AGE);
@@ -6,9 +6,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@Mixin(SkeletonSkullBlock.class) @Mixin(SkeletonSkullBlock.class)
public class SkeletonSkullBlockOverwrite { public class SkeletonSkullBlockOverwrite {
@Unique
private static Box boundingBox(BlockState state) { private static Box boundingBox(BlockState state) {
return switch (state.get(SkeletonSkullBlock.FACING)) { return switch (state.get(SkeletonSkullBlock.FACING)) {
default -> new Box(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f); default -> new Box(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f);
@@ -19,6 +21,7 @@ public class SkeletonSkullBlockOverwrite {
}; };
} }
@Unique
public Box getCollisionBox(World world, BlockPos pos, BlockState state) { public Box getCollisionBox(World world, BlockPos pos, BlockState state) {
return boundingBox(state); return boundingBox(state);
} }

Some files were not shown because too many files have changed in this diff Show More