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);
|
||||
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user