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:
+6
-6
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -9,13 +9,13 @@ import java.util.Iterator;
|
||||
|
||||
public class BiomeColors {
|
||||
private static final ColorProvider GRASS_COLOR = (biome, pos) -> {
|
||||
double d = (double) MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
|
||||
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
|
||||
double d = MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
|
||||
double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
|
||||
return GrassColors.getColor(d, e);
|
||||
};
|
||||
private static final ColorProvider FOLIAGE_COLOR = (biome, pos) -> {
|
||||
double d = (double) MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
|
||||
double e = (double) MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
|
||||
double d = MathHelper.clamp(biome.getTemperature(pos), 0.0F, 1.0F);
|
||||
double e = MathHelper.clamp(biome.getRainfall(), 0.0F, 1.0F);
|
||||
return FoliageColors.getColor(d, e);
|
||||
};
|
||||
private static final ColorProvider WATER_COLOR = (biome, pos) -> biome.getWaterColor();
|
||||
@@ -26,7 +26,7 @@ public class BiomeColors {
|
||||
int k = 0;
|
||||
|
||||
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();
|
||||
l = provider.getColorAtPos(view.getBiome(mutable), mutable);
|
||||
i += (l & 16711680) >> 16;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
|
||||
import net.minecraft.block.BlockState;
|
||||
+9
-10
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
|
||||
import net.minecraft.block.*;
|
||||
@@ -18,7 +18,7 @@ public class BlockColors {
|
||||
public static BlockColors create() {
|
||||
final BlockColors blockColors = new BlockColors();
|
||||
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;
|
||||
}, Blocks.DOUBLE_PLANT);
|
||||
blockColors.method_12158((blockState, blockView, blockPos, i) -> {
|
||||
@@ -37,7 +37,7 @@ public class BlockColors {
|
||||
}, 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) -> {
|
||||
PlanksBlock.WoodType woodType = (PlanksBlock.WoodType) blockState.get(Leaves1Block.VARIANT);
|
||||
PlanksBlock.WoodType woodType = blockState.get(Leaves1Block.VARIANT);
|
||||
if (woodType == PlanksBlock.WoodType.SPRUCE) {
|
||||
return net.minecraft.client.color.world.FoliageColors.getSpruceColor();
|
||||
} else if (woodType == PlanksBlock.WoodType.BIRCH) {
|
||||
@@ -48,10 +48,10 @@ public class BlockColors {
|
||||
}, 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.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) -> {
|
||||
int j = (Integer) blockState.get(AttachedStemBlock.AGE);
|
||||
int j = blockState.get(AttachedStemBlock.AGE);
|
||||
int k = j * 32;
|
||||
int l = 255 - j * 8;
|
||||
int m = j * 4;
|
||||
@@ -70,9 +70,9 @@ public class BlockColors {
|
||||
}
|
||||
|
||||
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) {
|
||||
return blockColorable.method_12155(blockState, null, (BlockPos) null, 0);
|
||||
return blockColorable.method_12155(blockState, null, null, 0);
|
||||
} else {
|
||||
MaterialColor materialColor = blockState.getMaterialColor();
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
public void method_12158(BlockColorable blockColorable, Block... blocks) {
|
||||
int var4 = blocks.length;
|
||||
|
||||
for (int var5 = 0; var5 < var4; ++var5) {
|
||||
Block block = blocks[var5];
|
||||
for (Block block : blocks) {
|
||||
this.BlockColor2Id.set(blockColorable, Block.getIdByBlock(block));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
public class FoliageColors {
|
||||
private static int[] colorMap = new int[65536];
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
public class GrassColors {
|
||||
private static int[] colorMap = new int[65536];
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.u9g.minecraftdatagenerator.ClientSideAnnoyances;
|
||||
package dev.u9g.minecraftdatagenerator.clientsideannoyances;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
+1
-1
@@ -2,7 +2,7 @@ package dev.u9g.minecraftdatagenerator.generators;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.SkyColor;
|
||||
import dev.u9g.minecraftdatagenerator.clientsideannoyances.SkyColor;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
|
||||
+12
-21
@@ -93,31 +93,22 @@ public class BlockCollisionShapesDataGenerator implements IDataGenerator {
|
||||
return shapes;
|
||||
}
|
||||
|
||||
private static class Shapes {
|
||||
final List<Box> boxes;
|
||||
|
||||
public Shapes(List<Box> boxes) {
|
||||
this.boxes = boxes;
|
||||
}
|
||||
private record Shapes(List<Box> boxes) {
|
||||
|
||||
public JsonArray toJSON() {
|
||||
JsonArray arr = new JsonArray();
|
||||
boxes.forEach(box -> arr.add(jsonOf(box)));
|
||||
return arr;
|
||||
}
|
||||
JsonArray arr = new JsonArray();
|
||||
boxes.forEach(box -> arr.add(jsonOf(box)));
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Shapes shapes = (Shapes) o;
|
||||
return Objects.equals(boxes, shapes.boxes);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Shapes shapes = (Shapes) o;
|
||||
return Objects.equals(boxes, shapes.boxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return boxes != null ? boxes.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,16 +45,16 @@ public class DataGenerators {
|
||||
try {
|
||||
Files.createDirectories(outputDirectory);
|
||||
} 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();
|
||||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
logger.log(Level.INFO, MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
|
||||
logger.info(MessageFormat.format("Running generator {0}", dataGenerator.getDataName()));
|
||||
try {
|
||||
String outputFileName = String.format("%s.json", dataGenerator.getDataName());
|
||||
JsonElement outputElement = dataGenerator.generateDataJson();
|
||||
@@ -65,16 +65,16 @@ public class DataGenerators {
|
||||
jsonWriter.setIndent(" ");
|
||||
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) {
|
||||
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();
|
||||
generatorsFailed++;
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Finishing running data generators");
|
||||
logger.info("Finishing running data generators");
|
||||
return generatorsFailed == 0;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -49,7 +49,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
private static String getCategoryFrom(@NotNull Class<?> entityClass) {
|
||||
if (entityClass == PlayerEntity.class) return "other"; // fail early for player entities
|
||||
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.boss", "net.minecraft.entity.mob", "net.minecraft.entity.boss.dragon" ->
|
||||
"Hostile mobs";
|
||||
@@ -59,7 +59,6 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity" -> "other";
|
||||
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
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@ package dev.u9g.minecraftdatagenerator.generators;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BiomeColors;
|
||||
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.BlockColors;
|
||||
import dev.u9g.minecraftdatagenerator.ClientSideAnnoyances.ServerSideRedstoneWireBlock;
|
||||
import dev.u9g.minecraftdatagenerator.clientsideannoyances.BiomeColors;
|
||||
import dev.u9g.minecraftdatagenerator.clientsideannoyances.BlockColors;
|
||||
import dev.u9g.minecraftdatagenerator.clientsideannoyances.ServerSideRedstoneWireBlock;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
|
||||
import dev.u9g.minecraftdatagenerator.util.EmptyBlockView;
|
||||
import dev.u9g.minecraftdatagenerator.util.Registries;
|
||||
|
||||
@@ -16,12 +16,12 @@ import java.util.logging.Level;
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
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();
|
||||
Path serverRootDirectory = DGU.getCurrentlyRunningServer().getRunDirectory().toPath().toAbsolutePath();
|
||||
Path dataDumpDirectory = serverRootDirectory.resolve("minecraft-data").resolve(versionName);
|
||||
DataGenerators.runDataGenerators(dataDumpDirectory);
|
||||
Main.LOGGER.log(Level.INFO, "Done data generation!");
|
||||
System.exit(0);
|
||||
Main.LOGGER.info("Done data generation!");
|
||||
Runtime.getRuntime().halt(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user