Small improvements (#22)
* Remove sky color hardcoding * Bind to available port instead of 25565 * Fix error class and reduce accessors * Fix language errors * Cleanup imports and remove weird behaviour * Print properly message * Print version name * Bump gson, update API usage and use linkedhashset over list * Reimplement approach to categories * Enable all feature flags by default * Use jul instead of slf4j * Call mc repo before maven central to fix build on mac
This commit is contained in:
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-89
@@ -6,7 +6,6 @@ import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import net.minecraft.world.biome.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -21,94 +20,8 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
return "overworld";
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeDisplayNamed) {
|
||||
if (biomeDisplayNamed.equals("Redwood Taiga Hills M")) {
|
||||
biomeDisplayNamed = "MegaTaigaHills";
|
||||
}
|
||||
String biomeDisplayName = StringUtils.join(biomeDisplayNamed.split(" "), "");
|
||||
return switch (biomeDisplayName) {
|
||||
case "Ocean" -> 112;
|
||||
case "Plains" -> 9286496;
|
||||
case "Desert" -> 16421912;
|
||||
case "ExtremeHills", "Extreme Hills" -> 6316128;
|
||||
case "Forest" -> 353825;
|
||||
case "Taiga" -> 747097;
|
||||
case "Swampland" -> 522674;
|
||||
case "River" -> 255;
|
||||
case "Hell" -> 16711680;
|
||||
case "TheEnd", "The End" -> 8421631;
|
||||
case "FrozenOcean", "Frozen Ocean" -> 7368918;
|
||||
case "FrozenRiver", "Frozen River" -> 10526975;
|
||||
case "IcePlains", "Ice Plains" -> 16777215;
|
||||
case "IceMountains", "Ice Mountains" -> 10526880;
|
||||
case "MushroomIsland", "Mushroom Island" -> 16711935;
|
||||
case "MushroomIslandShore", "Mushroom Island Shore" -> 10486015;
|
||||
case "Beach" -> 16440917;
|
||||
case "DesertHills", "Desert Hills" -> 13786898;
|
||||
case "ForestHills", "Forest Hills" -> 2250012;
|
||||
case "TaigaHills", "Taiga Hills" -> 1456435;
|
||||
case "ExtremeHillsEdge", "Extreme Hills Edge" -> 7501978;
|
||||
case "Jungle" -> 5470985;
|
||||
case "JungleHills", "Jungle Hills" -> 2900485;
|
||||
case "JungleEdge", "Jungle Edge" -> 6458135;
|
||||
case "DeepOcean", "Deep Ocean" -> 48;
|
||||
case "StoneBeach", "Stone Beach" -> 10658436;
|
||||
case "ColdBeach", "Cold Beach" -> 16445632;
|
||||
case "BirchForest", "Birch Forest" -> 3175492;
|
||||
case "BirchForestHills", "Birch Forest Hills" -> 2055986;
|
||||
case "RoofedForest", "Roofed Forest" -> 4215066;
|
||||
case "ColdTaiga", "Cold Taiga" -> 3233098;
|
||||
case "ColdTaigaHills", "Cold Taiga Hills" -> 2375478;
|
||||
case "MegaTaiga", "Mega Taiga" -> 5858897;
|
||||
case "MegaTaigaHills", "Mega Taiga Hills" -> 4542270;
|
||||
case "ExtremeHills+", "Extreme Hills+" -> 5271632;
|
||||
case "Savanna" -> 12431967;
|
||||
case "SavannaPlateau", "Savanna Plateau" -> 10984804;
|
||||
case "Mesa" -> 14238997;
|
||||
case "MesaPlateauF", "Mesa Plateau F" -> 11573093;
|
||||
case "MesaPlateau", "Mesa Plateau" -> 13274213;
|
||||
case "TheEnd-Floatingislands", "The End - Floating islands" -> 8421631;
|
||||
case "TheEnd-Mediumisland", "The End - Medium island" -> 8421631;
|
||||
case "TheEnd-Highisland", "The End - High island" -> 8421631;
|
||||
case "TheEnd-Barrenisland", "The End - Barren island" -> 8421631;
|
||||
case "WarmOcean", "Warm Ocean" -> 172;
|
||||
case "LukewarmOcean", "Lukewarm Ocean" -> 144;
|
||||
case "ColdOcean", "Cold Ocean" -> 2105456;
|
||||
case "WarmDeepOcean", "Warm Deep Ocean" -> 80;
|
||||
case "LukewarmDeepOcean", "Lukewarm Deep Ocean" -> 64;
|
||||
case "ColdDeepOcean", "Cold Deep Ocean" -> 2105400;
|
||||
case "FrozenDeepOcean", "Frozen Deep Ocean" -> 4210832;
|
||||
case "TheVoid", "The Void" -> 0;
|
||||
case "SunflowerPlains", "Sunflower Plains" -> 11918216;
|
||||
case "DesertM", "Desert M" -> 16759872;
|
||||
case "ExtremeHillsM", "Extreme Hills M" -> 8947848;
|
||||
case "FlowerForest", "Flower Forest" -> 2985545;
|
||||
case "TaigaM", "Taiga M" -> 3378817;
|
||||
case "SwamplandM", "Swampland M" -> 3145690;
|
||||
case "IcePlainsSpikes", "Ice Plains Spikes" -> 11853020;
|
||||
case "JungleM", "Jungle M" -> 8102705;
|
||||
case "JungleEdgeM", "Jungle Edge M" -> 9089855;
|
||||
case "BirchForestM", "Birch Forest M" -> 5807212;
|
||||
case "BirchForestHillsM", "Birch Forest Hills M" -> 4687706;
|
||||
case "RoofedForestM", "Roofed Forest M" -> 6846786;
|
||||
case "ColdTaigaM", "Cold Taiga M" -> 5864818;
|
||||
case "MegaSpruceTaiga", "Mega Spruce Taiga" -> 8490617;
|
||||
case "MegaSpruceTaiga(Hills)", "Mega Spruce Taiga (Hills)" -> 7173990;
|
||||
case "ExtremeHills+M", "Extreme Hills+ M" -> 7903352;
|
||||
case "SavannaM", "Savanna M" -> 15063687;
|
||||
case "SavannaPlateauM", "Savanna Plateau M" -> 13616524;
|
||||
case "Mesa(Bryce)", "Mesa (Bryce)" -> 16739645;
|
||||
case "MesaPlateauFM", "Mesa Plateau F M" -> 14204813;
|
||||
case "MesaPlateauM", "Mesa Plateau M" -> 15905933;
|
||||
case "BambooJungle", "Bamboo Jungle" -> 7769620;
|
||||
case "BambooJungleHills", "Bamboo Jungle Hills" -> 3884810;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeDisplayName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(SimpleRegistry<Identifier, Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getIdentifier(biome);
|
||||
|
||||
biomeDesc.addProperty("id", registry.getRawId(biome));
|
||||
biomeDesc.addProperty("name", String.join("_", ((BiomeAccessor) biome).name().toLowerCase(Locale.ENGLISH).split(" ")));
|
||||
@@ -118,7 +31,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", ((BiomeAccessor) biome).name());
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(((BiomeAccessor) biome).name()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor(biome.getTemperature()));
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
@@ -160,7 +73,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
} else if (biome instanceof StoneBeachBiome || biome instanceof VoidBiome) {
|
||||
return "none"; // Should StoneBeachBiome be beach too? this is how it is now in mcdata
|
||||
}
|
||||
throw new Error("Unable to find biome category for " + biome.getClass().getName());
|
||||
throw new IllegalStateException("Unable to find biome category for " + biome.getClass().getName());
|
||||
}
|
||||
|
||||
private static String precipitation(Biome biome) {
|
||||
|
||||
+4
-5
@@ -38,8 +38,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entity == null ? 0 : entity.width);
|
||||
entityDesc.addProperty("height", entity == null ? 0 : entity.height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
entityTypeString = getEntityTypeForClass(entityClass);
|
||||
String entityTypeString = getEntityTypeForClass(entityClass);
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityClass));
|
||||
|
||||
@@ -62,7 +61,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + packageName);
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + packageName);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
|
||||
private static int entityId(Entity entity) {
|
||||
if (!DGU.getCurrentlyRunningServer().getVersion().equals("1.10.2")) {
|
||||
throw new Error("These ids were gotten manually for 1.10.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
throw new IllegalStateException("These ids were gotten manually for 1.10.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
}
|
||||
int rawId = Registries.ENTITY_TYPES.getRawId(entity.getClass());
|
||||
if (rawId == -1) { // see TrackedEntityInstance
|
||||
@@ -114,7 +113,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
} else if (entity instanceof FishingBobberEntity) {
|
||||
return 90;
|
||||
} else {
|
||||
throw new Error("unable to find rawId for entity: " + entity.getEntityName());
|
||||
throw new IllegalStateException("unable to find rawId for entity: " + entity.getEntityName());
|
||||
}
|
||||
}
|
||||
return rawId;
|
||||
|
||||
+11
-17
@@ -9,9 +9,8 @@ import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
|
||||
@@ -25,13 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
return items;
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
List<EnchantmentTarget> targets = new ArrayList<>();
|
||||
for (EnchantmentTarget target : EnchantmentTarget.values()) {
|
||||
if (!target.isCompatible(sourceItem)) continue;
|
||||
targets.add(target);
|
||||
}
|
||||
return targets;
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isCompatible(sourceItem))
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Item item) {
|
||||
@@ -44,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", item.getDisplayName(DGU.stackFor(item)));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(new JsonPrimitive(EnchantmentsDataGenerator.getEnchantmentTargetName(target)));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -62,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = Registries.ITEMS.getIdentifier(repairWithItem);
|
||||
fixedWithArray.add(new JsonPrimitive(Objects.requireNonNull(repairWithName).getPath()));
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
obj.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,28 +9,13 @@ import java.util.Map;
|
||||
|
||||
@Mixin(EntityType.class)
|
||||
public interface EntityTypeAccessor {
|
||||
@Accessor("NAME_CLASS_MAP")
|
||||
static Map<String, Class<? extends Entity>> NAME_CLASS_MAP() {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@Accessor("CLASS_NAME_MAP")
|
||||
static Map<Class<? extends Entity>, String> CLASS_NAME_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("ID_CLASS_MAP")
|
||||
static Map<Integer, Class<? extends Entity>> ID_CLASS_MAP() {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@Accessor("CLASS_ID_MAP")
|
||||
static Map<Class<? extends Entity>, Integer> CLASS_ID_MAP() {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@Accessor("NAME_ID_MAP")
|
||||
static Map<String, Integer> NAME_ID_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
} else if (biome instanceof StoneBeachBiome || biome instanceof VoidBiome) {
|
||||
return "none"; // Should StoneBeachBiome be beach too? this is how it is now in mcdata
|
||||
}
|
||||
throw new Error("Unable to find biome category for " + biome.getClass().getName());
|
||||
throw new IllegalStateException("Unable to find biome category for " + biome.getClass().getName());
|
||||
}
|
||||
|
||||
private static String precipitation(Biome biome) {
|
||||
|
||||
+4
-5
@@ -39,8 +39,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entity == null ? 0 : entity.width);
|
||||
entityDesc.addProperty("height", entity == null ? 0 : entity.height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
entityTypeString = getEntityTypeForClass(entityClass);
|
||||
String entityTypeString = getEntityTypeForClass(entityClass);
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityClass));
|
||||
|
||||
@@ -62,7 +61,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + packageName);
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + packageName);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
|
||||
private static int entityId(Entity entity) {
|
||||
if (!DGU.getCurrentlyRunningServer().getVersion().equals("1.11.2")) {
|
||||
throw new Error("These ids were gotten manually for 1.11.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
throw new IllegalStateException("These ids were gotten manually for 1.11.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
}
|
||||
int rawId = Registries.ENTITY_TYPES.getRawId(entity.getClass());
|
||||
if (rawId == -1) { // see TrackedEntityInstance
|
||||
@@ -114,7 +113,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
} else if (entity instanceof FishingBobberEntity) {
|
||||
return 90;
|
||||
} else {
|
||||
throw new Error("unable to find rawId for entity: " + entity.getEntityName());
|
||||
throw new IllegalStateException("unable to find rawId for entity: " + entity.getEntityName());
|
||||
}
|
||||
}
|
||||
return rawId;
|
||||
|
||||
+11
-17
@@ -9,9 +9,8 @@ import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
|
||||
@@ -25,13 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
return items;
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
List<EnchantmentTarget> targets = new ArrayList<>();
|
||||
for (EnchantmentTarget target : EnchantmentTarget.values()) {
|
||||
if (!target.isCompatible(sourceItem)) continue;
|
||||
targets.add(target);
|
||||
}
|
||||
return targets;
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isCompatible(sourceItem))
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Item item) {
|
||||
@@ -44,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(new JsonPrimitive(EnchantmentsDataGenerator.getEnchantmentTargetName(target)));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -62,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = Registries.ITEMS.getIdentifier(repairWithItem);
|
||||
fixedWithArray.add(new JsonPrimitive(Objects.requireNonNull(repairWithName).getPath()));
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
obj.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-89
@@ -6,7 +6,6 @@ import dev.u9g.minecraftdatagenerator.mixin.BiomeAccessor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import net.minecraft.world.biome.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -21,94 +20,8 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
return "overworld";
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeDisplayNamed) {
|
||||
if (biomeDisplayNamed.equals("Redwood Taiga Hills M")) {
|
||||
biomeDisplayNamed = "MegaTaigaHills";
|
||||
}
|
||||
String biomeDisplayName = StringUtils.join(biomeDisplayNamed.split(" "), "");
|
||||
return switch (biomeDisplayName) {
|
||||
case "Ocean" -> 112;
|
||||
case "Plains" -> 9286496;
|
||||
case "Desert" -> 16421912;
|
||||
case "ExtremeHills", "Extreme Hills" -> 6316128;
|
||||
case "Forest" -> 353825;
|
||||
case "Taiga" -> 747097;
|
||||
case "Swampland" -> 522674;
|
||||
case "River" -> 255;
|
||||
case "Hell" -> 16711680;
|
||||
case "TheEnd", "The End" -> 8421631;
|
||||
case "FrozenOcean", "Frozen Ocean" -> 7368918;
|
||||
case "FrozenRiver", "Frozen River" -> 10526975;
|
||||
case "IcePlains", "Ice Plains" -> 16777215;
|
||||
case "IceMountains", "Ice Mountains" -> 10526880;
|
||||
case "MushroomIsland", "Mushroom Island" -> 16711935;
|
||||
case "MushroomIslandShore", "Mushroom Island Shore" -> 10486015;
|
||||
case "Beach" -> 16440917;
|
||||
case "DesertHills", "Desert Hills" -> 13786898;
|
||||
case "ForestHills", "Forest Hills" -> 2250012;
|
||||
case "TaigaHills", "Taiga Hills" -> 1456435;
|
||||
case "ExtremeHillsEdge", "Extreme Hills Edge" -> 7501978;
|
||||
case "Jungle" -> 5470985;
|
||||
case "JungleHills", "Jungle Hills" -> 2900485;
|
||||
case "JungleEdge", "Jungle Edge" -> 6458135;
|
||||
case "DeepOcean", "Deep Ocean" -> 48;
|
||||
case "StoneBeach", "Stone Beach" -> 10658436;
|
||||
case "ColdBeach", "Cold Beach" -> 16445632;
|
||||
case "BirchForest", "Birch Forest" -> 3175492;
|
||||
case "BirchForestHills", "Birch Forest Hills" -> 2055986;
|
||||
case "RoofedForest", "Roofed Forest" -> 4215066;
|
||||
case "ColdTaiga", "Cold Taiga" -> 3233098;
|
||||
case "ColdTaigaHills", "Cold Taiga Hills" -> 2375478;
|
||||
case "MegaTaiga", "Mega Taiga" -> 5858897;
|
||||
case "MegaTaigaHills", "Mega Taiga Hills" -> 4542270;
|
||||
case "ExtremeHills+", "Extreme Hills+" -> 5271632;
|
||||
case "Savanna" -> 12431967;
|
||||
case "SavannaPlateau", "Savanna Plateau" -> 10984804;
|
||||
case "Mesa" -> 14238997;
|
||||
case "MesaPlateauF", "Mesa Plateau F" -> 11573093;
|
||||
case "MesaPlateau", "Mesa Plateau" -> 13274213;
|
||||
case "TheEnd-Floatingislands", "The End - Floating islands" -> 8421631;
|
||||
case "TheEnd-Mediumisland", "The End - Medium island" -> 8421631;
|
||||
case "TheEnd-Highisland", "The End - High island" -> 8421631;
|
||||
case "TheEnd-Barrenisland", "The End - Barren island" -> 8421631;
|
||||
case "WarmOcean", "Warm Ocean" -> 172;
|
||||
case "LukewarmOcean", "Lukewarm Ocean" -> 144;
|
||||
case "ColdOcean", "Cold Ocean" -> 2105456;
|
||||
case "WarmDeepOcean", "Warm Deep Ocean" -> 80;
|
||||
case "LukewarmDeepOcean", "Lukewarm Deep Ocean" -> 64;
|
||||
case "ColdDeepOcean", "Cold Deep Ocean" -> 2105400;
|
||||
case "FrozenDeepOcean", "Frozen Deep Ocean" -> 4210832;
|
||||
case "TheVoid", "The Void" -> 0;
|
||||
case "SunflowerPlains", "Sunflower Plains" -> 11918216;
|
||||
case "DesertM", "Desert M" -> 16759872;
|
||||
case "ExtremeHillsM", "Extreme Hills M" -> 8947848;
|
||||
case "FlowerForest", "Flower Forest" -> 2985545;
|
||||
case "TaigaM", "Taiga M" -> 3378817;
|
||||
case "SwamplandM", "Swampland M" -> 3145690;
|
||||
case "IcePlainsSpikes", "Ice Plains Spikes" -> 11853020;
|
||||
case "JungleM", "Jungle M" -> 8102705;
|
||||
case "JungleEdgeM", "Jungle Edge M" -> 9089855;
|
||||
case "BirchForestM", "Birch Forest M" -> 5807212;
|
||||
case "BirchForestHillsM", "Birch Forest Hills M" -> 4687706;
|
||||
case "RoofedForestM", "Roofed Forest M" -> 6846786;
|
||||
case "ColdTaigaM", "Cold Taiga M" -> 5864818;
|
||||
case "MegaSpruceTaiga", "Mega Spruce Taiga" -> 8490617;
|
||||
case "MegaSpruceTaiga(Hills)", "Mega Spruce Taiga (Hills)" -> 7173990;
|
||||
case "ExtremeHills+M", "Extreme Hills+ M" -> 7903352;
|
||||
case "SavannaM", "Savanna M" -> 15063687;
|
||||
case "SavannaPlateauM", "Savanna Plateau M" -> 13616524;
|
||||
case "Mesa(Bryce)", "Mesa (Bryce)" -> 16739645;
|
||||
case "MesaPlateauFM", "Mesa Plateau F M" -> 14204813;
|
||||
case "MesaPlateauM", "Mesa Plateau M" -> 15905933;
|
||||
case "BambooJungle", "Bamboo Jungle" -> 7769620;
|
||||
case "BambooJungleHills", "Bamboo Jungle Hills" -> 3884810;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeDisplayName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(SimpleRegistry<Identifier, Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getIdentifier(biome);
|
||||
|
||||
String name = String.join("_", ((BiomeAccessor) biome).name().toLowerCase(Locale.ENGLISH).split(" "));
|
||||
String displayName = ((BiomeAccessor) biome).name();
|
||||
@@ -120,7 +33,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", displayName);
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(displayName));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor(biome.getTemperature()));
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
@@ -162,7 +75,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
} else if (biome instanceof StoneBeachBiome || biome instanceof VoidBiome) {
|
||||
return "none"; // Should StoneBeachBiome be beach too? this is how it is now in mcdata
|
||||
}
|
||||
throw new Error("Unable to find biome category for " + biome.getClass().getName());
|
||||
throw new IllegalStateException("Unable to find biome category for " + biome.getClass().getName());
|
||||
}
|
||||
|
||||
private static String precipitation(Biome biome) {
|
||||
|
||||
+4
-5
@@ -39,8 +39,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entity == null ? 0 : entity.width);
|
||||
entityDesc.addProperty("height", entity == null ? 0 : entity.height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
entityTypeString = getEntityTypeForClass(entityClass);
|
||||
String entityTypeString = getEntityTypeForClass(entityClass);
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityClass));
|
||||
|
||||
@@ -62,7 +61,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + packageName);
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + packageName);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
|
||||
private static int entityId(Entity entity) {
|
||||
if (!DGU.getCurrentlyRunningServer().getVersion().equals("1.12.2")) {
|
||||
throw new Error("These ids were gotten manually for 1.12.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
throw new IllegalStateException("These ids were gotten manually for 1.12.2, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
}
|
||||
int rawId = Registries.ENTITY_TYPES.getRawId(entity.getClass());
|
||||
if (rawId == -1) { // see TrackedEntityInstance
|
||||
@@ -114,7 +113,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
} else if (entity instanceof FishingBobberEntity) {
|
||||
return 90;
|
||||
} else {
|
||||
throw new Error("unable to find rawId for entity: " + entity.getEntityName());
|
||||
throw new IllegalStateException("unable to find rawId for entity: " + entity.getEntityName());
|
||||
}
|
||||
}
|
||||
return rawId;
|
||||
|
||||
+11
-17
@@ -8,9 +8,8 @@ import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
|
||||
@@ -24,13 +23,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
return items;
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
List<EnchantmentTarget> targets = new ArrayList<>();
|
||||
for (EnchantmentTarget target : EnchantmentTarget.values()) {
|
||||
if (!target.isCompatible(sourceItem)) continue;
|
||||
targets.add(target);
|
||||
}
|
||||
return targets;
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isCompatible(sourceItem))
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Item item) {
|
||||
@@ -43,13 +41,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -61,7 +55,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = Registries.ITEMS.getIdentifier(repairWithItem);
|
||||
fixedWithArray.add(Objects.requireNonNull(repairWithName).getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
obj.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-83
@@ -20,88 +20,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "ocean" -> 112;
|
||||
case "plains" -> 9286496;
|
||||
case "desert" -> 16421912;
|
||||
case "mountains" -> 6316128;
|
||||
case "forest" -> 353825;
|
||||
case "taiga" -> 747097;
|
||||
case "swamp" -> 522674;
|
||||
case "river" -> 255;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "the_end" -> 8421631;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "snowy_tundra" -> 16777215;
|
||||
case "snowy_mountains" -> 10526880;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "mushroom_field_shore" -> 10486015;
|
||||
case "beach" -> 16440917;
|
||||
case "desert_hills" -> 13786898;
|
||||
case "wooded_hills" -> 2250012;
|
||||
case "taiga_hills" -> 1456435;
|
||||
case "mountain_edge" -> 7501978;
|
||||
case "jungle" -> 5470985;
|
||||
case "jungle_hills" -> 2900485;
|
||||
case "jungle_edge" -> 6458135;
|
||||
case "deep_ocean" -> 48;
|
||||
case "stone_shore" -> 10658436;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "birch_forest_hills" -> 2055986;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "snowy_taiga_hills" -> 2375478;
|
||||
case "giant_tree_taiga" -> 5858897;
|
||||
case "giant_tree_taiga_hills" -> 4542270;
|
||||
case "wooded_mountains" -> 5271632;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "badlands" -> 14238997;
|
||||
case "wooded_badlands_plateau" -> 11573093;
|
||||
case "badlands_plateau" -> 13274213;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_barrens" -> 9474162;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_warm_ocean" -> 80;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "the_void" -> 0;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "desert_lakes" -> 16759872;
|
||||
case "gravelly_mountains" -> 8947848;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "taiga_mountains" -> 3378817;
|
||||
case "swamp_hills" -> 3145690;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "modified_jungle" -> 8102705;
|
||||
case "modified_jungle_edge" -> 9089855;
|
||||
case "tall_birch_forest" -> 5807212;
|
||||
case "tall_birch_hills" -> 4687706;
|
||||
case "dark_forest_hills" -> 6846786;
|
||||
case "snowy_taiga_mountains" -> 5864818;
|
||||
case "giant_spruce_taiga" -> 8490617;
|
||||
case "giant_spruce_taiga_hills" -> 7173990;
|
||||
case "modified_gravelly_mountains" -> 7903352;
|
||||
case "shattered_savanna" -> 15063687;
|
||||
case "shattered_savanna_plateau" -> 13616524;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "modified_wooded_badlands_plateau" -> 14204813;
|
||||
case "modified_badlands_plateau" -> 15905933;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "bamboo_jungle_hills" -> 3884810;
|
||||
case "nether" -> 16711680;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getId(biome);
|
||||
@@ -116,7 +34,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor(biome.getTemperature()));
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+2
-3
@@ -39,8 +39,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entity == null ? 0 : entity.width);
|
||||
entityDesc.addProperty("height", entity == null ? 0 : entity.height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
entityTypeString = getEntityTypeForClass(entityClass);
|
||||
String entityTypeString = getEntityTypeForClass(entityClass);
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityType));
|
||||
|
||||
@@ -84,7 +83,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + packageName);
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + packageName);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+10
-17
@@ -9,9 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -23,13 +21,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
List<EnchantmentTarget> targets = new ArrayList<>();
|
||||
for (EnchantmentTarget target : EnchantmentTarget.values()) {
|
||||
if (!target.isCompatible(sourceItem)) continue;
|
||||
targets.add(target);
|
||||
}
|
||||
return targets;
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isCompatible(sourceItem))
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -42,13 +39,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -60,7 +53,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getId(repairWithItem);
|
||||
fixedWithArray.add(Objects.requireNonNull(repairWithName).getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-83
@@ -18,88 +18,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "ocean" -> 112;
|
||||
case "plains" -> 9286496;
|
||||
case "desert" -> 16421912;
|
||||
case "mountains" -> 6316128;
|
||||
case "forest" -> 353825;
|
||||
case "taiga" -> 747097;
|
||||
case "swamp" -> 522674;
|
||||
case "river" -> 255;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "the_end" -> 8421631;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "snowy_tundra" -> 16777215;
|
||||
case "snowy_mountains" -> 10526880;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "mushroom_field_shore" -> 10486015;
|
||||
case "beach" -> 16440917;
|
||||
case "desert_hills" -> 13786898;
|
||||
case "wooded_hills" -> 2250012;
|
||||
case "taiga_hills" -> 1456435;
|
||||
case "mountain_edge" -> 7501978;
|
||||
case "jungle" -> 5470985;
|
||||
case "jungle_hills" -> 2900485;
|
||||
case "jungle_edge" -> 6458135;
|
||||
case "deep_ocean" -> 48;
|
||||
case "stone_shore" -> 10658436;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "birch_forest_hills" -> 2055986;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "snowy_taiga_hills" -> 2375478;
|
||||
case "giant_tree_taiga" -> 5858897;
|
||||
case "giant_tree_taiga_hills" -> 4542270;
|
||||
case "wooded_mountains" -> 5271632;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "badlands" -> 14238997;
|
||||
case "wooded_badlands_plateau" -> 11573093;
|
||||
case "badlands_plateau" -> 13274213;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_barrens" -> 9474162;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_warm_ocean" -> 80;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "the_void" -> 0;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "desert_lakes" -> 16759872;
|
||||
case "gravelly_mountains" -> 8947848;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "taiga_mountains" -> 3378817;
|
||||
case "swamp_hills" -> 3145690;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "modified_jungle" -> 8102705;
|
||||
case "modified_jungle_edge" -> 9089855;
|
||||
case "tall_birch_forest" -> 5807212;
|
||||
case "tall_birch_hills" -> 4687706;
|
||||
case "dark_forest_hills" -> 6846786;
|
||||
case "snowy_taiga_mountains" -> 5864818;
|
||||
case "giant_spruce_taiga" -> 8490617;
|
||||
case "giant_spruce_taiga_hills" -> 7173990;
|
||||
case "modified_gravelly_mountains" -> 7903352;
|
||||
case "shattered_savanna" -> 15063687;
|
||||
case "shattered_savanna_plateau" -> 13616524;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "modified_wooded_badlands_plateau" -> 14204813;
|
||||
case "modified_badlands_plateau" -> 15905933;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "bamboo_jungle_hills" -> 3884810;
|
||||
case "nether" -> 16711680;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getId(biome);
|
||||
@@ -114,7 +32,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor(biome.getTemperature()));
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+3
-4
@@ -33,9 +33,8 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entityType.getWidth());
|
||||
entityDesc.addProperty("height", entityType.getHeight());
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
Entity entityObject = entityType.create(DGU.getWorld());
|
||||
entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
String entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityType));
|
||||
|
||||
@@ -46,7 +45,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "other"; // fail early for player entities
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.remove();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -56,7 +55,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+8
-12
@@ -9,9 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -23,10 +21,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -39,13 +39,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxAmount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -57,7 +53,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getId(repairWithItem);
|
||||
fixedWithArray.add(Objects.requireNonNull(repairWithName).getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-83
@@ -19,88 +19,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "ocean" -> 112;
|
||||
case "plains" -> 9286496;
|
||||
case "desert" -> 16421912;
|
||||
case "mountains" -> 6316128;
|
||||
case "forest" -> 353825;
|
||||
case "taiga" -> 747097;
|
||||
case "swamp" -> 522674;
|
||||
case "river" -> 255;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "the_end" -> 8421631;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "snowy_tundra" -> 16777215;
|
||||
case "snowy_mountains" -> 10526880;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "mushroom_field_shore" -> 10486015;
|
||||
case "beach" -> 16440917;
|
||||
case "desert_hills" -> 13786898;
|
||||
case "wooded_hills" -> 2250012;
|
||||
case "taiga_hills" -> 1456435;
|
||||
case "mountain_edge" -> 7501978;
|
||||
case "jungle" -> 5470985;
|
||||
case "jungle_hills" -> 2900485;
|
||||
case "jungle_edge" -> 6458135;
|
||||
case "deep_ocean" -> 48;
|
||||
case "stone_shore" -> 10658436;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "birch_forest_hills" -> 2055986;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "snowy_taiga_hills" -> 2375478;
|
||||
case "giant_tree_taiga" -> 5858897;
|
||||
case "giant_tree_taiga_hills" -> 4542270;
|
||||
case "wooded_mountains" -> 5271632;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "badlands" -> 14238997;
|
||||
case "wooded_badlands_plateau" -> 11573093;
|
||||
case "badlands_plateau" -> 13274213;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_barrens" -> 9474162;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_warm_ocean" -> 80;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "the_void" -> 0;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "desert_lakes" -> 16759872;
|
||||
case "gravelly_mountains" -> 8947848;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "taiga_mountains" -> 3378817;
|
||||
case "swamp_hills" -> 3145690;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "modified_jungle" -> 8102705;
|
||||
case "modified_jungle_edge" -> 9089855;
|
||||
case "tall_birch_forest" -> 5807212;
|
||||
case "tall_birch_hills" -> 4687706;
|
||||
case "dark_forest_hills" -> 6846786;
|
||||
case "snowy_taiga_mountains" -> 5864818;
|
||||
case "giant_spruce_taiga" -> 8490617;
|
||||
case "giant_spruce_taiga_hills" -> 7173990;
|
||||
case "modified_gravelly_mountains" -> 7903352;
|
||||
case "shattered_savanna" -> 15063687;
|
||||
case "shattered_savanna_plateau" -> 13616524;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "modified_wooded_badlands_plateau" -> 14204813;
|
||||
case "modified_badlands_plateau" -> 15905933;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "bamboo_jungle_hills" -> 3884810;
|
||||
case "nether" -> 16711680;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getId(biome);
|
||||
@@ -114,7 +32,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor());
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+3
-4
@@ -33,9 +33,8 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entityType.getDimensions().width);
|
||||
entityDesc.addProperty("height", entityType.getDimensions().height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
Entity entityObject = entityType.create(DGU.getWorld());
|
||||
entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
String entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityType));
|
||||
|
||||
@@ -46,7 +45,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "other"; // fail early for player entities
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.remove();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -57,7 +56,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+8
-12
@@ -9,9 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -23,10 +21,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -39,13 +39,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -57,7 +53,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getId(repairWithItem);
|
||||
fixedWithArray.add(Objects.requireNonNull(repairWithName).getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-86
@@ -17,91 +17,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "ocean" -> 112;
|
||||
case "plains" -> 9286496;
|
||||
case "desert" -> 16421912;
|
||||
case "mountains" -> 6316128;
|
||||
case "forest" -> 353825;
|
||||
case "taiga" -> 747097;
|
||||
case "swamp" -> 522674;
|
||||
case "river" -> 255;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "the_end" -> 8421631;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "snowy_tundra" -> 16777215;
|
||||
case "snowy_mountains" -> 10526880;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "mushroom_field_shore" -> 10486015;
|
||||
case "beach" -> 16440917;
|
||||
case "desert_hills" -> 13786898;
|
||||
case "wooded_hills" -> 2250012;
|
||||
case "taiga_hills" -> 1456435;
|
||||
case "mountain_edge" -> 7501978;
|
||||
case "jungle" -> 5470985;
|
||||
case "jungle_hills" -> 2900485;
|
||||
case "jungle_edge" -> 6458135;
|
||||
case "deep_ocean" -> 48;
|
||||
case "stone_shore" -> 10658436;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "birch_forest_hills" -> 2055986;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "snowy_taiga_hills" -> 2375478;
|
||||
case "giant_tree_taiga" -> 5858897;
|
||||
case "giant_tree_taiga_hills" -> 4542270;
|
||||
case "wooded_mountains" -> 5271632;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "badlands" -> 14238997;
|
||||
case "wooded_badlands_plateau" -> 11573093;
|
||||
case "badlands_plateau" -> 13274213;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_barrens" -> 9474162;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_warm_ocean" -> 80;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "the_void" -> 0;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "desert_lakes" -> 16759872;
|
||||
case "gravelly_mountains" -> 8947848;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "taiga_mountains" -> 3378817;
|
||||
case "swamp_hills" -> 3145690;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "modified_jungle" -> 8102705;
|
||||
case "modified_jungle_edge" -> 9089855;
|
||||
case "tall_birch_forest" -> 5807212;
|
||||
case "tall_birch_hills" -> 4687706;
|
||||
case "dark_forest_hills" -> 6846786;
|
||||
case "snowy_taiga_mountains" -> 5864818;
|
||||
case "giant_spruce_taiga" -> 8490617;
|
||||
case "giant_spruce_taiga_hills" -> 7173990;
|
||||
case "modified_gravelly_mountains" -> 7903352;
|
||||
case "shattered_savanna" -> 15063687;
|
||||
case "shattered_savanna_plateau" -> 13616524;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "modified_wooded_badlands_plateau" -> 14204813;
|
||||
case "modified_badlands_plateau" -> 15905933;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "bamboo_jungle_hills" -> 3884810;
|
||||
case "soul_sand_valley" -> 6174768;
|
||||
case "crimson_forest" -> 14485512;
|
||||
case "warped_forest" -> 4821115;
|
||||
case "basalt_deltas" -> 4208182;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue();
|
||||
@@ -116,7 +31,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor());
|
||||
biomeDesc.addProperty("rainfall", biome.getRainfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+3
-4
@@ -32,10 +32,9 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entityType.getDimensions().width);
|
||||
entityDesc.addProperty("height", entityType.getDimensions().height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
MinecraftServer minecraftServer = DGU.getCurrentlyRunningServer();
|
||||
Entity entityObject = entityType.create(minecraftServer.getOverworld());
|
||||
entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
String entityTypeString = entityObject != null ? getEntityTypeForClass(entityObject.getClass()) : "player";
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityType));
|
||||
|
||||
@@ -46,7 +45,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "other"; // fail early for player entities
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.remove();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -56,7 +55,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -10,7 +10,9 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -22,10 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -38,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-68
@@ -18,73 +18,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "the_void" -> 0;
|
||||
case "plains" -> 9286496;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "snowy_plains" -> 16777215;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "desert" -> 16421912;
|
||||
case "swamp" -> 522674;
|
||||
case "forest" -> 353825;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "old_growth_birch_forest" -> 5807212;
|
||||
case "old_growth_pine_taiga" -> 5858897;
|
||||
case "old_growth_spruce_taiga" -> 8490617;
|
||||
case "taiga" -> 747097;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "windswept_hills" -> 6316128;
|
||||
case "windswept_gravelly_hills" -> 8947848;
|
||||
case "windswept_forest" -> 2250012;
|
||||
case "windswept_savanna" -> 15063687;
|
||||
case "jungle" -> 5470985;
|
||||
case "sparse_jungle" -> 6458135;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "badlands" -> 14238997;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "wooded_badlands" -> 11573093;
|
||||
case "meadow" -> 9217136;
|
||||
case "grove" -> 14675173;
|
||||
case "snowy_slopes" -> 14348785;
|
||||
case "frozen_peaks" -> 15399931;
|
||||
case "jagged_peaks" -> 14937325;
|
||||
case "stony_peaks" -> 13750737;
|
||||
case "river" -> 255;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "beach" -> 16440917;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "stony_shore" -> 10658436;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "ocean" -> 112;
|
||||
case "deep_ocean" -> 48;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "dripstone_caves" -> 12690831;
|
||||
case "lush_caves" -> 14652980;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "warped_forest" -> 4821115;
|
||||
case "crimson_forest" -> 14485512;
|
||||
case "soul_sand_valley" -> 6174768;
|
||||
case "basalt_deltas" -> 4208182;
|
||||
case "the_end" -> 8421631;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_barrens" -> 9474162;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue();
|
||||
@@ -99,7 +32,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.getDepth());
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor());
|
||||
biomeDesc.addProperty("rainfall", biome.getDownfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN"; // fail early for player entities
|
||||
Entity entity = EntityType.createInstanceFromId(Registry.ENTITY_TYPE.getRawId(entityType), DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -58,7 +58,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -10,7 +10,9 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -22,10 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -38,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-68
@@ -18,73 +18,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeName) {
|
||||
return switch (biomeName) {
|
||||
case "the_void" -> 0;
|
||||
case "plains" -> 9286496;
|
||||
case "sunflower_plains" -> 11918216;
|
||||
case "snowy_plains" -> 16777215;
|
||||
case "ice_spikes" -> 11853020;
|
||||
case "desert" -> 16421912;
|
||||
case "swamp" -> 522674;
|
||||
case "forest" -> 353825;
|
||||
case "flower_forest" -> 2985545;
|
||||
case "birch_forest" -> 3175492;
|
||||
case "dark_forest" -> 4215066;
|
||||
case "old_growth_birch_forest" -> 5807212;
|
||||
case "old_growth_pine_taiga" -> 5858897;
|
||||
case "old_growth_spruce_taiga" -> 8490617;
|
||||
case "taiga" -> 747097;
|
||||
case "snowy_taiga" -> 3233098;
|
||||
case "savanna" -> 12431967;
|
||||
case "savanna_plateau" -> 10984804;
|
||||
case "windswept_hills" -> 6316128;
|
||||
case "windswept_gravelly_hills" -> 8947848;
|
||||
case "windswept_forest" -> 2250012;
|
||||
case "windswept_savanna" -> 15063687;
|
||||
case "jungle" -> 5470985;
|
||||
case "sparse_jungle" -> 6458135;
|
||||
case "bamboo_jungle" -> 7769620;
|
||||
case "badlands" -> 14238997;
|
||||
case "eroded_badlands" -> 16739645;
|
||||
case "wooded_badlands" -> 11573093;
|
||||
case "meadow" -> 9217136;
|
||||
case "grove" -> 14675173;
|
||||
case "snowy_slopes" -> 14348785;
|
||||
case "frozen_peaks" -> 15399931;
|
||||
case "jagged_peaks" -> 14937325;
|
||||
case "stony_peaks" -> 13750737;
|
||||
case "river" -> 255;
|
||||
case "frozen_river" -> 10526975;
|
||||
case "beach" -> 16440917;
|
||||
case "snowy_beach" -> 16445632;
|
||||
case "stony_shore" -> 10658436;
|
||||
case "warm_ocean" -> 172;
|
||||
case "lukewarm_ocean" -> 144;
|
||||
case "deep_lukewarm_ocean" -> 64;
|
||||
case "ocean" -> 112;
|
||||
case "deep_ocean" -> 48;
|
||||
case "cold_ocean" -> 2105456;
|
||||
case "deep_cold_ocean" -> 2105400;
|
||||
case "frozen_ocean" -> 7368918;
|
||||
case "deep_frozen_ocean" -> 4210832;
|
||||
case "mushroom_fields" -> 16711935;
|
||||
case "dripstone_caves" -> 12690831;
|
||||
case "lush_caves" -> 14652980;
|
||||
case "nether_wastes" -> 12532539;
|
||||
case "warped_forest" -> 4821115;
|
||||
case "crimson_forest" -> 14485512;
|
||||
case "soul_sand_valley" -> 6174768;
|
||||
case "basalt_deltas" -> 4208182;
|
||||
case "the_end" -> 8421631;
|
||||
case "end_highlands" -> 12828041;
|
||||
case "end_midlands" -> 15464630;
|
||||
case "small_end_islands" -> 42;
|
||||
case "end_barrens" -> 9474162;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue();
|
||||
@@ -99,7 +32,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
//biomeDesc.addProperty("depth", biome.getDepth()); - Doesn't exist anymore in minecraft source
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey));
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor());
|
||||
biomeDesc.addProperty("rainfall", biome.getDownfall());
|
||||
|
||||
return biomeDesc;
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN"; // fail early for player entities
|
||||
Entity entity = EntityType.createInstanceFromId(Registry.ENTITY_TYPE.getRawId(entityType), DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -58,7 +58,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -10,7 +10,9 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -22,10 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -38,15 +42,11 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
|
||||
if (item.isDamageable()) itemDesc.addProperty("maxDurability", item.getMaxDamage());
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN";
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -58,7 +58,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -10,7 +10,9 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -22,10 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -38,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN";
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -58,7 +58,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -10,7 +10,9 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -22,10 +24,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -38,13 +42,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN";
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -63,7 +63,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -11,7 +11,9 @@ import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -23,10 +25,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -39,13 +43,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SoulFire
|
||||
* Copyright (C) 2024 AlexProgrammerDE
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
import net.minecraft.resource.DataPackSettings;
|
||||
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DataPackSettings.class)
|
||||
public class DataPackSettingsMixin {
|
||||
@Inject(method = "getEnabled", at = @At("HEAD"), cancellable = true)
|
||||
public void getEnabled(CallbackInfoReturnable<List<String>> cir) {
|
||||
cir.setReturnValue(FeatureFlags.FEATURE_MANAGER.toId(FeatureFlags.FEATURE_MANAGER.getFeatureSet()).stream().map(Identifier::getPath).toList());
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"package": "dev.u9g.minecraftdatagenerator.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"DataPackSettingsMixin",
|
||||
"EULAMixin",
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin"
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN";
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -63,7 +63,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -5,16 +5,17 @@ import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.util.DGU;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.BuiltinRegistries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -26,13 +27,13 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<TagKey<Item>> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return sourceItem.getComponents().get(DataComponentTypes.ENCHANTMENTS)
|
||||
.getEnchantments()
|
||||
.stream()
|
||||
.map(RegistryEntry::value)
|
||||
private static Set<String> getApplicableEnchantmentTargets(RegistryEntry<Item> sourceItem) {
|
||||
return DGU.getWorld().getRegistryManager().get(RegistryKeys.ENCHANTMENT).stream()
|
||||
.map(Enchantment::getApplicableItems)
|
||||
.toList();
|
||||
.filter(sourceItem::isIn)
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -45,13 +46,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<TagKey<Item>> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (TagKey<Item> target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(itemRegistry.getEntry(item)).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -63,7 +60,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ToolComponent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
@@ -85,7 +86,7 @@ public class MaterialsDataGenerator implements IDataGenerator {
|
||||
itemRegistry.forEach(item -> {
|
||||
if (item instanceof MiningToolItem toolItem) {
|
||||
item.getComponents().get(DataComponentTypes.TOOL).rules()
|
||||
.stream().map(rule -> rule.blocks())
|
||||
.stream().map(ToolComponent.Rule::blocks)
|
||||
.forEach(blocks -> {
|
||||
Optional<TagKey<Block>> tagKey = blocks.getTagKey();
|
||||
if (tagKey.isPresent()) {
|
||||
@@ -137,7 +138,7 @@ public class MaterialsDataGenerator implements IDataGenerator {
|
||||
//Tools are handled rather easily and do not require anything else
|
||||
if (item instanceof MiningToolItem toolItem) {
|
||||
item.getComponents().get(DataComponentTypes.TOOL).rules()
|
||||
.stream().map(rule -> rule.blocks())
|
||||
.stream().map(ToolComponent.Rule::blocks)
|
||||
.forEach(blocks -> {
|
||||
Optional<TagKey<Block>> tagKey = blocks.getTagKey();
|
||||
if (tagKey.isPresent()) {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SoulFire
|
||||
* Copyright (C) 2024 AlexProgrammerDE
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
import net.minecraft.resource.DataPackSettings;
|
||||
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DataPackSettings.class)
|
||||
public class DataPackSettingsMixin {
|
||||
@Inject(method = "getEnabled", at = @At("HEAD"), cancellable = true)
|
||||
public void getEnabled(CallbackInfoReturnable<List<String>> cir) {
|
||||
cir.setReturnValue(FeatureFlags.FEATURE_MANAGER.toId(FeatureFlags.FEATURE_MANAGER.getFeatureSet()).stream().map(Identifier::getPath).toList());
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"package": "dev.u9g.minecraftdatagenerator.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"DataPackSettingsMixin",
|
||||
"EULAMixin",
|
||||
"ReadyMixin"
|
||||
],
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
if (entityType == EntityType.PLAYER) return "UNKNOWN";
|
||||
Entity entity = entityType.create(DGU.getWorld());
|
||||
if (entity == null)
|
||||
throw new Error("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
throw new IllegalStateException("Entity was null after trying to create a: " + DGU.translateText(entityType.getTranslationKey()));
|
||||
entity.discard();
|
||||
return switch (entity.getClass().getPackageName()) {
|
||||
case "net.minecraft.entity.decoration", "net.minecraft.entity.decoration.painting" -> "Immobile";
|
||||
@@ -59,7 +59,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "UNKNOWN";
|
||||
default -> throw new Error("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + entity.getClass().getPackageName());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -11,7 +11,9 @@ import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
@@ -23,10 +25,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isAcceptableItem(sourceItem))
|
||||
.collect(Collectors.toList());
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Registry<Item> itemRegistry, Item item) {
|
||||
@@ -39,13 +43,9 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", DGU.translateText(item.getTranslationKey()));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(EnchantmentsDataGenerator.getEnchantmentTargetName(target));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
Identifier repairWithName = itemRegistry.getKey(repairWithItem).orElseThrow().getValue();
|
||||
fixedWithArray.add(repairWithName.getPath());
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
try {
|
||||
InputStream inputStream = Objects.requireNonNull(this.getClass().getResourceAsStream("/assets/minecraft/lang/en_us.json"));
|
||||
return new Gson().fromJson(new InputStreamReader(inputStream, StandardCharsets.UTF_8), JsonObject.class);
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SoulFire
|
||||
* Copyright (C) 2024 AlexProgrammerDE
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package dev.u9g.minecraftdatagenerator.mixin;
|
||||
|
||||
import net.minecraft.resource.DataPackSettings;
|
||||
import net.minecraft.resource.featuretoggle.FeatureFlags;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(DataPackSettings.class)
|
||||
public class DataPackSettingsMixin {
|
||||
@Inject(method = "getEnabled", at = @At("HEAD"), cancellable = true)
|
||||
public void getEnabled(CallbackInfoReturnable<List<String>> cir) {
|
||||
cir.setReturnValue(FeatureFlags.FEATURE_MANAGER.toId(FeatureFlags.FEATURE_MANAGER.getFeatureSet()).stream().map(Identifier::getPath).toList());
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
MinecraftDataGenerator.start(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"package": "dev.u9g.minecraftdatagenerator.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"DataPackSettingsMixin",
|
||||
"EULAMixin",
|
||||
"MiningToolItemAccessor",
|
||||
"ReadyMixin"
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-88
@@ -5,7 +5,6 @@ import com.google.gson.JsonObject;
|
||||
import dev.u9g.minecraftdatagenerator.mixin.accessor.BiomeAccessor;
|
||||
import dev.u9g.minecraftdatagenerator.util.Registries;
|
||||
import net.minecraft.world.biome.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.SortedMap;
|
||||
@@ -22,91 +21,6 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
return "overworld";
|
||||
}
|
||||
|
||||
private static int getBiomeColorFor(String biomeDisplayNamed) {
|
||||
if (biomeDisplayNamed.equals("Redwood Taiga Hills M")) {
|
||||
biomeDisplayNamed = "MegaTaigaHills";
|
||||
}
|
||||
String biomeDisplayName = StringUtils.join(biomeDisplayNamed.split(" "), "");
|
||||
return switch (biomeDisplayName) {
|
||||
case "Ocean" -> 112;
|
||||
case "Plains" -> 9286496;
|
||||
case "Desert" -> 16421912;
|
||||
case "ExtremeHills", "Extreme Hills" -> 6316128;
|
||||
case "Forest" -> 353825;
|
||||
case "Taiga" -> 747097;
|
||||
case "Swampland" -> 522674;
|
||||
case "River" -> 255;
|
||||
case "Hell" -> 16711680;
|
||||
case "TheEnd", "The End" -> 8421631;
|
||||
case "FrozenOcean", "Frozen Ocean" -> 7368918;
|
||||
case "FrozenRiver", "Frozen River" -> 10526975;
|
||||
case "IcePlains", "Ice Plains" -> 16777215;
|
||||
case "IceMountains", "Ice Mountains" -> 10526880;
|
||||
case "MushroomIsland", "Mushroom Island" -> 16711935;
|
||||
case "MushroomIslandShore", "Mushroom Island Shore" -> 10486015;
|
||||
case "Beach" -> 16440917;
|
||||
case "DesertHills", "Desert Hills" -> 13786898;
|
||||
case "ForestHills", "Forest Hills" -> 2250012;
|
||||
case "TaigaHills", "Taiga Hills" -> 1456435;
|
||||
case "ExtremeHillsEdge", "Extreme Hills Edge" -> 7501978;
|
||||
case "Jungle" -> 5470985;
|
||||
case "JungleHills", "Jungle Hills" -> 2900485;
|
||||
case "JungleEdge", "Jungle Edge" -> 6458135;
|
||||
case "DeepOcean", "Deep Ocean" -> 48;
|
||||
case "StoneBeach", "Stone Beach" -> 10658436;
|
||||
case "ColdBeach", "Cold Beach" -> 16445632;
|
||||
case "BirchForest", "Birch Forest" -> 3175492;
|
||||
case "BirchForestHills", "Birch Forest Hills" -> 2055986;
|
||||
case "RoofedForest", "Roofed Forest" -> 4215066;
|
||||
case "ColdTaiga", "Cold Taiga" -> 3233098;
|
||||
case "ColdTaigaHills", "Cold Taiga Hills" -> 2375478;
|
||||
case "MegaTaiga", "Mega Taiga" -> 5858897;
|
||||
case "MegaTaigaHills", "Mega Taiga Hills" -> 4542270;
|
||||
case "ExtremeHills+", "Extreme Hills+" -> 5271632;
|
||||
case "Savanna" -> 12431967;
|
||||
case "SavannaPlateau", "Savanna Plateau" -> 10984804;
|
||||
case "Mesa" -> 14238997;
|
||||
case "MesaPlateauF", "Mesa Plateau F" -> 11573093;
|
||||
case "MesaPlateau", "Mesa Plateau" -> 13274213;
|
||||
case "TheEnd-Floatingislands", "The End - Floating islands" -> 8421631;
|
||||
case "TheEnd-Mediumisland", "The End - Medium island" -> 8421631;
|
||||
case "TheEnd-Highisland", "The End - High island" -> 8421631;
|
||||
case "TheEnd-Barrenisland", "The End - Barren island" -> 8421631;
|
||||
case "WarmOcean", "Warm Ocean" -> 172;
|
||||
case "LukewarmOcean", "Lukewarm Ocean" -> 144;
|
||||
case "ColdOcean", "Cold Ocean" -> 2105456;
|
||||
case "WarmDeepOcean", "Warm Deep Ocean" -> 80;
|
||||
case "LukewarmDeepOcean", "Lukewarm Deep Ocean" -> 64;
|
||||
case "ColdDeepOcean", "Cold Deep Ocean" -> 2105400;
|
||||
case "FrozenDeepOcean", "Frozen Deep Ocean" -> 4210832;
|
||||
case "TheVoid", "The Void" -> 0;
|
||||
case "SunflowerPlains", "Sunflower Plains" -> 11918216;
|
||||
case "DesertM", "Desert M" -> 16759872;
|
||||
case "ExtremeHillsM", "Extreme Hills M" -> 8947848;
|
||||
case "FlowerForest", "Flower Forest" -> 2985545;
|
||||
case "TaigaM", "Taiga M" -> 3378817;
|
||||
case "SwamplandM", "Swampland M" -> 3145690;
|
||||
case "IcePlainsSpikes", "Ice Plains Spikes" -> 11853020;
|
||||
case "JungleM", "Jungle M" -> 8102705;
|
||||
case "JungleEdgeM", "Jungle Edge M" -> 9089855;
|
||||
case "BirchForestM", "Birch Forest M" -> 5807212;
|
||||
case "BirchForestHillsM", "Birch Forest Hills M" -> 4687706;
|
||||
case "RoofedForestM", "Roofed Forest M" -> 6846786;
|
||||
case "ColdTaigaM", "Cold Taiga M" -> 5864818;
|
||||
case "MegaSpruceTaiga", "Mega Spruce Taiga" -> 8490617;
|
||||
case "MegaSpruceTaiga(Hills)", "Mega Spruce Taiga (Hills)" -> 7173990;
|
||||
case "ExtremeHills+M", "Extreme Hills+ M" -> 7903352;
|
||||
case "SavannaM", "Savanna M" -> 15063687;
|
||||
case "SavannaPlateauM", "Savanna Plateau M" -> 13616524;
|
||||
case "Mesa(Bryce)", "Mesa (Bryce)" -> 16739645;
|
||||
case "MesaPlateauFM", "Mesa Plateau F M" -> 14204813;
|
||||
case "MesaPlateauM", "Mesa Plateau M" -> 15905933;
|
||||
case "BambooJungle", "Bamboo Jungle" -> 7769620;
|
||||
case "BambooJungleHills", "Bamboo Jungle Hills" -> 3884810;
|
||||
default -> throw new Error("Unexpected biome, with name: '" + biomeDisplayName + "'");
|
||||
};
|
||||
}
|
||||
|
||||
public static JsonObject generateBiomeInfo(Biome biome) {
|
||||
JsonObject biomeDesc = new JsonObject();
|
||||
|
||||
@@ -118,7 +32,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
biomeDesc.addProperty("depth", biome.depth);
|
||||
biomeDesc.addProperty("dimension", guessBiomeDimensionFromCategory(biome));
|
||||
biomeDesc.addProperty("displayName", ((BiomeAccessor) biome).name());
|
||||
biomeDesc.addProperty("color", getBiomeColorFor(((BiomeAccessor) biome).name()));
|
||||
biomeDesc.addProperty("color", biome.getSkyColor(biome.temperature));
|
||||
biomeDesc.addProperty("rainfall", biome.downfall);
|
||||
|
||||
return biomeDesc;
|
||||
@@ -160,7 +74,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
} else if (biome instanceof StoneBeachBiome) {
|
||||
return "none"; // Should StoneBeachBiome be beach too? this is how it is now in mcdata
|
||||
}
|
||||
throw new Error("Unable to find biome category for " + biome.getClass().getName());
|
||||
throw new IllegalStateException("Unable to find biome category for " + biome.getClass().getName());
|
||||
}
|
||||
|
||||
private static String precipitation(Biome biome) {
|
||||
|
||||
+4
-5
@@ -37,8 +37,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
entityDesc.addProperty("width", entity == null ? 0 : entity.width);
|
||||
entityDesc.addProperty("height", entity == null ? 0 : entity.height);
|
||||
|
||||
String entityTypeString = "UNKNOWN";
|
||||
entityTypeString = getEntityTypeForClass(entityClass);
|
||||
String entityTypeString = getEntityTypeForClass(entityClass);
|
||||
entityDesc.addProperty("type", entityTypeString);
|
||||
entityDesc.addProperty("category", getCategoryFrom(entityClass));
|
||||
|
||||
@@ -61,7 +60,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
case "net.minecraft.entity.passive" -> "Passive mobs";
|
||||
case "net.minecraft.entity.vehicle" -> "Vehicles";
|
||||
case "net.minecraft.entity" -> "other";
|
||||
default -> throw new Error("Unexpected entity type: " + packageName);
|
||||
default -> throw new IllegalStateException("Unexpected entity type: " + packageName);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
|
||||
private static int entityId(Entity entity) {
|
||||
if (!DGU.getCurrentlyRunningServer().getVersion().equals("1.7")) {
|
||||
throw new Error("These ids were gotten manually for 1.7, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
throw new IllegalStateException("These ids were gotten manually for 1.7, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
}
|
||||
int rawId = Registries.ENTITY_TYPES.getRawId(entity.getClass());
|
||||
if (rawId == -1) { // see TrackedEntityInstance
|
||||
@@ -113,7 +112,7 @@ public class EntitiesDataGenerator implements IDataGenerator {
|
||||
} else if (entity instanceof FishingBobberEntity) {
|
||||
return 90;
|
||||
} else {
|
||||
throw new Error("unable to find rawId for entity: " + entity.getClass().getName());
|
||||
throw new IllegalStateException("unable to find rawId for entity: " + entity.getClass().getName());
|
||||
}
|
||||
}
|
||||
return rawId;
|
||||
|
||||
+13
-21
@@ -12,9 +12,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.VariantBlockItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemsDataGenerator implements IDataGenerator {
|
||||
|
||||
@@ -28,13 +27,12 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
return items;
|
||||
}
|
||||
|
||||
private static List<EnchantmentTarget> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
List<EnchantmentTarget> targets = new ArrayList<>();
|
||||
for (EnchantmentTarget target : EnchantmentTarget.values()) {
|
||||
if (!target.isCompatible(sourceItem)) continue;
|
||||
targets.add(target);
|
||||
}
|
||||
return targets;
|
||||
private static Set<String> getApplicableEnchantmentTargets(Item sourceItem) {
|
||||
return Arrays.stream(EnchantmentTarget.values())
|
||||
.filter(target -> target.isCompatible(sourceItem))
|
||||
.map(EnchantmentsDataGenerator::getEnchantmentTargetName)
|
||||
.sorted()
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
public static JsonObject generateItem(Item item) {
|
||||
@@ -48,16 +46,10 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
itemDesc.addProperty("displayName", item.getDisplayName(DGU.stackFor(item)));
|
||||
itemDesc.addProperty("stackSize", item.getMaxCount());
|
||||
|
||||
List<EnchantmentTarget> enchantmentTargets = getApplicableEnchantmentTargets(item);
|
||||
|
||||
if (item.isDamageable()) {
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
for (EnchantmentTarget target : enchantmentTargets) {
|
||||
enchantCategoriesArray.add(new JsonPrimitive(EnchantmentsDataGenerator.getEnchantmentTargetName(target)));
|
||||
}
|
||||
if (enchantCategoriesArray.size() > 0) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
JsonArray enchantCategoriesArray = new JsonArray();
|
||||
getApplicableEnchantmentTargets(item).forEach(enchantCategoriesArray::add);
|
||||
if (!enchantCategoriesArray.isEmpty()) {
|
||||
itemDesc.add("enchantCategories", enchantCategoriesArray);
|
||||
}
|
||||
|
||||
if (item.isDamageable()) {
|
||||
@@ -68,7 +60,7 @@ public class ItemsDataGenerator implements IDataGenerator {
|
||||
String repairWithName = Registries.ITEMS.getId(repairWithItem);
|
||||
fixedWithArray.add(new JsonPrimitive(Objects.requireNonNull(repairWithName)));
|
||||
}
|
||||
if (fixedWithArray.size() > 0) {
|
||||
if (!fixedWithArray.isEmpty()) {
|
||||
itemDesc.add("repairWith", fixedWithArray);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,8 +22,8 @@ public class LanguageDataGenerator implements IDataGenerator {
|
||||
obj.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return obj;
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to generate language file", e);
|
||||
}
|
||||
throw new RuntimeException("Failed to generate language file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ import java.io.File;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class ReadyMixin {
|
||||
@Inject(method = "setupServer()Z", at = @At("HEAD"))
|
||||
private void constructor(CallbackInfoReturnable<Boolean> cir) {
|
||||
((MinecraftDedicatedServer) (Object) this).setServerPort(0);
|
||||
}
|
||||
|
||||
@Inject(method = "setupServer()Z", at = @At("TAIL"))
|
||||
private void init(CallbackInfoReturnable<Boolean> cir) {
|
||||
System.setProperty("fabric.development", "false");
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Set;
|
||||
public interface BiomeAccessor {
|
||||
@Accessor("BIOMESET")
|
||||
static Set<Biome> BIOMESET() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("waterColor")
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
public interface EnchantmentAccessor {
|
||||
@Accessor("ALL_ENCHANTMENTS")
|
||||
static Enchantment[] ALL_ENCHANTMENTS() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-8
@@ -9,23 +9,18 @@ import java.util.Map;
|
||||
|
||||
@Mixin(EntityType.class)
|
||||
public interface EntityTypeAccessor {
|
||||
@Accessor("NAME_CLASS_MAP")
|
||||
static Map<String, Class<? extends Entity>> NAME_CLASS_MAP() {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
@Accessor("CLASS_NAME_MAP")
|
||||
static Map<Class<? extends Entity>, String> CLASS_NAME_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("ID_CLASS_MAP")
|
||||
static Map<Integer, Class<? extends Entity>> ID_CLASS_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("CLASS_ID_MAP")
|
||||
static Map<Class<? extends Entity>, Integer> CLASS_ID_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
public interface StatusEffectAccessor {
|
||||
@Accessor("STATUS_EFFECTS")
|
||||
static StatusEffect[] STATUS_EFFECTS() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("negative")
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ public class TableBackedRegistryView<K, V> implements RegistryView<K, V> {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
throw new Error("value not in registry.");
|
||||
throw new IllegalStateException("value not in registry.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +34,7 @@ public class TableBackedRegistryView<K, V> implements RegistryView<K, V> {
|
||||
return row.getKey();
|
||||
}
|
||||
}
|
||||
throw new Error("value not in registry.");
|
||||
throw new IllegalStateException("value not in registry.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,3 +45,9 @@ tasks.withType(RemapJarTask).configureEach {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class BiomesDataGenerator implements IDataGenerator {
|
||||
} else if (biome instanceof StoneBeachBiome) {
|
||||
return "none"; // Should StoneBeachBiome be beach too? this is how it is now in mcdata
|
||||
}
|
||||
throw new Error("Unable to find biome category for " + biome.getClass().getName());
|
||||
throw new IllegalStateException("Unable to find biome category for " + biome.getClass().getName());
|
||||
}
|
||||
|
||||
private static String precipitation(Biome biome) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user