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))
|
||||
}
|
||||
}
|
||||
|
||||
+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) {
|
||||
|
||||
+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.8.9")) {
|
||||
throw new Error("These ids were gotten manually for 1.8.9, remake for " + DGU.getCurrentlyRunningServer().getVersion());
|
||||
throw new IllegalStateException("These ids were gotten manually for 1.8.9, 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.getEntity().getClass().getName());
|
||||
throw new IllegalStateException("unable to find rawId for entity: " + entity.getEntity().getClass().getName());
|
||||
}
|
||||
}
|
||||
return rawId;
|
||||
|
||||
+13
-21
@@ -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,16 +42,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()) {
|
||||
@@ -64,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,7 +10,7 @@ import java.util.Set;
|
||||
public interface BiomeAccessor {
|
||||
@Accessor("BIOMESET")
|
||||
static Set<Biome> BIOMESET() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("waterColor")
|
||||
|
||||
@@ -11,6 +11,6 @@ import java.util.Map;
|
||||
public interface EnchantmentAccessor {
|
||||
@Accessor("ENCHANTMENT_MAP")
|
||||
static Map<Identifier, Enchantment> ENCHANTMENT_MAP() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
public interface StatusEffectAccessor {
|
||||
@Accessor("STATUS_EFFECTS_BY_ID")
|
||||
static Map<Identifier, StatusEffect> STATUS_EFFECTS_BY_ID() {
|
||||
throw new Error();
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Accessor("negative")
|
||||
|
||||
Reference in New Issue
Block a user