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