Add NBT matching to list of valid block/item entries (#1771)

Co-authored-by: Jason Mitchell <[email protected]>
This commit is contained in:
Eclipse-SolandJason Mitchell authored and GitHub committed 2026-05-23 23:08:48 -07:00
1 parent c9633fd745
commit dd1d3aa518
15 files changed
+1132 -252

No files matched your search

@@ -1,5 +1,6 @@
package net.coderbot.iris.shaderpack.materialmap;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -10,14 +11,15 @@ import java.util.Map;
* In 1.7.10, entities are registered with names like "CaveSpider".
* Some entities were also renamed or split into multiple types.
*
* This map is used at lookup time: when a modern shader pack references an entity by its
* modern name, we resolve it to the 1.7.10 name that EntityList uses.
*/
public class EntityFlatteningMap {
/** Maps modern entity name -> 1.7.10 entity name. */
private static final Map<String, String> MODERN_TO_LEGACY = new HashMap<>();
/** Maps modern entity name -> legacy entity name + NBT. */
private static final Map<String, BlockEntry> MODERN_TO_LEGACY_NBT = new HashMap<>();
static {
// Simple case changes
simple("Arrow", "arrow");
@@ -35,7 +37,6 @@ public class EntityFlatteningMap {
simple("Pig", "pig");
simple("Sheep", "sheep");
simple("Silverfish", "silverfish");
simple("Skeleton", "skeleton");
simple("Slime", "slime");
simple("Snowball", "snowball");
simple("Spider", "spider");
@@ -49,7 +50,6 @@ public class EntityFlatteningMap {
simple("CaveSpider", "cave_spider");
simple("EnderCrystal", "end_crystal");
simple("EnderDragon", "ender_dragon");
simple("EntityHorse", "horse");
simple("EyeOfEnderSignal", "eye_of_ender");
simple("FallingSand", "falling_block");
simple("Fireball", "fireball");
@@ -79,6 +79,36 @@ public class EntityFlatteningMap {
simple("MinecartHopper", "hopper_minecart");
simple("MinecartSpawner", "spawner_minecart");
simple("MinecartTNT", "tnt_minecart");
MODERN_TO_LEGACY_NBT.put("skeleton", new BlockEntry(
new NamespacedId("Skeleton"), Collections.emptySet(), Collections.emptyMap(),
Map.of("SkeletonType", new PropertiesTokenizer.NbtValue("0", false))));
MODERN_TO_LEGACY_NBT.put("wither_skeleton", new BlockEntry(
new NamespacedId("Skeleton"), Collections.emptySet(), Collections.emptyMap(),
Map.of("SkeletonType", new PropertiesTokenizer.NbtValue("1", false))));
// 1.7.10 EntityHorse with Type byte: 0=horse, 1=donkey, 2=mule, 3=zombie_horse,
// 4=skeleton_horse. 1.11+ split each into its own entity type.
MODERN_TO_LEGACY_NBT.put("horse", new BlockEntry(
new NamespacedId("EntityHorse"), Collections.emptySet(), Collections.emptyMap(),
Map.of("Type", new PropertiesTokenizer.NbtValue("0", false))));
MODERN_TO_LEGACY_NBT.put("donkey", new BlockEntry(
new NamespacedId("EntityHorse"), Collections.emptySet(), Collections.emptyMap(),
Map.of("Type", new PropertiesTokenizer.NbtValue("1", false))));
MODERN_TO_LEGACY_NBT.put("mule", new BlockEntry(
new NamespacedId("EntityHorse"), Collections.emptySet(), Collections.emptyMap(),
Map.of("Type", new PropertiesTokenizer.NbtValue("2", false))));
MODERN_TO_LEGACY_NBT.put("zombie_horse", new BlockEntry(
new NamespacedId("EntityHorse"), Collections.emptySet(), Collections.emptyMap(),
Map.of("Type", new PropertiesTokenizer.NbtValue("3", false))));
MODERN_TO_LEGACY_NBT.put("skeleton_horse", new BlockEntry(
new NamespacedId("EntityHorse"), Collections.emptySet(), Collections.emptyMap(),
Map.of("Type", new PropertiesTokenizer.NbtValue("4", false))));
// 1.7.10 Zombie with IsVillager.
MODERN_TO_LEGACY_NBT.put("zombie_villager", new BlockEntry(
new NamespacedId("Zombie"), Collections.emptySet(), Collections.emptyMap(),
Map.of("IsVillager", new PropertiesTokenizer.NbtValue("1", false))));
}
/**
@@ -89,6 +119,10 @@ public class EntityFlatteningMap {
return MODERN_TO_LEGACY.get(modernName);
}
public static BlockEntry toLegacyWithNbt(String modernName) {
return MODERN_TO_LEGACY_NBT.get(modernName);
}
private static void simple(String legacy, String modern) {
MODERN_TO_LEGACY.put(modern, legacy);
}