derive default layers, armor wearers, arms/chest pose flags and mob variant textures from the vanilla dump, drop the hardcoded lists
This commit is contained in:
1 parent
022b080fce
commit
a743dc32c7
14 files changed
+720
-162
No files matched your search
+81
-12
@@ -44,6 +44,49 @@ public class EntityTestRender {
|
||||
"minecart","end_crystal","arrow","trident","leash_knot","evoker_fangs","wither_skull","shulker_bullet","cushion"
|
||||
};
|
||||
|
||||
// "@variants" case set (before/after pixel diffs of variant / pose-flag / armor handling). Spec syntax:
|
||||
// [baby:]type[@variant][+flag…], flags: chest, arms, tame (red collar), saddle, armor (full diamond), noarmor.
|
||||
static final List<String> VARIANT_CASES = new ArrayList<>();
|
||||
static {
|
||||
for (String v : new String[] {"tabby", "black", "red", "siamese", "british_shorthair", "calico", "persian",
|
||||
"ragdoll", "white", "jellie", "all_black"}) {
|
||||
VARIANT_CASES.add("cat@" + v);
|
||||
VARIANT_CASES.add("baby:cat@" + v + "+tame");
|
||||
}
|
||||
for (String v : new String[] {"pale", "spotted", "snowy", "black", "ashen", "rusty", "woods", "chestnut",
|
||||
"striped"}) {
|
||||
VARIANT_CASES.add("wolf@" + v);
|
||||
VARIANT_CASES.add("wolf@" + v + "+tame");
|
||||
VARIANT_CASES.add("baby:wolf@" + v);
|
||||
VARIANT_CASES.add("baby:wolf@" + v + "+tame");
|
||||
}
|
||||
for (String t : new String[] {"cow", "pig", "chicken"})
|
||||
for (String v : new String[] {"temperate", "warm", "cold"}) {
|
||||
VARIANT_CASES.add(t + "@" + v);
|
||||
VARIANT_CASES.add("baby:" + t + "@" + v);
|
||||
}
|
||||
for (String v : new String[] {"temperate", "warm", "cold"}) VARIANT_CASES.add("frog@" + v);
|
||||
for (String v : new String[] {"temperate", "warm"}) VARIANT_CASES.add("zombie_nautilus@" + v);
|
||||
VARIANT_CASES.add("mooshroom@red");
|
||||
VARIANT_CASES.add("mooshroom@brown");
|
||||
VARIANT_CASES.add("baby:mooshroom@brown");
|
||||
// Armor stand with/without arms, small, with armor.
|
||||
for (String a : new String[] {"armor_stand", "armor_stand+arms", "baby:armor_stand", "baby:armor_stand+arms",
|
||||
"armor_stand+arms+armor", "baby:armor_stand+arms+armor"}) VARIANT_CASES.add(a);
|
||||
// Chests.
|
||||
for (String c : new String[] {"llama@creamy", "llama@creamy+chest", "llama@brown+chest+saddle", "llama@gray+chest",
|
||||
"trader_llama@white+chest", "baby:llama@creamy+chest", "donkey", "donkey+chest", "donkey+chest+saddle",
|
||||
"mule", "mule+chest", "mule+chest+saddle", "baby:donkey+chest"}) VARIANT_CASES.add(c);
|
||||
// Armor wearers (and non-wearers given armor: nothing must appear).
|
||||
for (String t : new String[] {"zombie", "husk", "drowned", "zombie_villager", "zombified_piglin", "skeleton",
|
||||
"stray", "wither_skeleton", "bogged", "parched", "piglin", "piglin_brute", "giant", "player",
|
||||
"mannequin", "armor_stand", "baby:zombie", "baby:piglin", "baby:zombified_piglin", "baby:husk",
|
||||
"baby:drowned", "baby:zombie_villager", "villager", "pillager", "vindicator", "witch", "cow", "pig",
|
||||
"creeper", "enderman", "evoker", "illusioner", "wandering_trader", "copper_golem", "fox", "panda"})
|
||||
VARIANT_CASES.add(t + "+armor");
|
||||
VARIANT_CASES.addAll(List.of(ENTITIES));
|
||||
}
|
||||
|
||||
// Representative variants (the game always supplies these; null base textures wouldn't exist otherwise).
|
||||
static final Map<String, String> VAR = Map.ofEntries(
|
||||
Map.entry("cat", "tabby"), Map.entry("wolf", "pale"), Map.entry("axolotl", "lucy"),
|
||||
@@ -135,7 +178,8 @@ public class EntityTestRender {
|
||||
WorldSnapshot empty = new WorldSnapshot(Map.of(), 0, 1, air);
|
||||
SkyContext sky = new SkyContext(6000, 0, 6000);
|
||||
|
||||
String[] list = args.length > 0 ? args : ENTITIES;
|
||||
String[] list = args.length == 0 ? ENTITIES
|
||||
: args[0].equals("@variants") ? VARIANT_CASES.toArray(new String[0]) : args;
|
||||
List<BufferedImage> cells = new ArrayList<>();
|
||||
for (String key : list) {
|
||||
BufferedImage v1 = renderEntity(renderer, baker, empty, sky, key, 45);
|
||||
@@ -144,13 +188,13 @@ public class EntityTestRender {
|
||||
log.info("rendered " + key);
|
||||
}
|
||||
|
||||
File outDir = new File("/home/elias/Dokumente/PixelPics-Entity-Renders");
|
||||
File outDir = new File(System.getProperty("out", "/home/elias/Dokumente/PixelPics-Entity-Renders"));
|
||||
outDir.mkdirs();
|
||||
// One image per entity (both 45°/225° views side by side), named by entity key.
|
||||
File single = new File(outDir, "einzeln");
|
||||
single.mkdirs();
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
ImageIO.write(cells.get(i), "png", new File(single, list[i].replace(':', '_') + ".png"));
|
||||
ImageIO.write(cells.get(i), "png", new File(single, list[i].replaceAll("[:@+]", "_") + ".png"));
|
||||
}
|
||||
|
||||
// Compose contact-sheet pages: 2 columns.
|
||||
@@ -177,15 +221,7 @@ public class EntityTestRender {
|
||||
|
||||
static BufferedImage renderEntity(DefaultScreenRenderer renderer, eu.mhsl.minecraft.pixelpics.render.entity.cem.CemBaker baker, WorldSnapshot world,
|
||||
SkyContext sky, String key, float yaw) {
|
||||
boolean baby = key.startsWith("baby:");
|
||||
if (baby) key = key.substring(5);
|
||||
boolean isPlayer = key.equals("player");
|
||||
int tint = key.equals("tropical_fish") ? 0xFFF9801D : (key.equals("sheep") ? 0xFFF9FFFE : 0);
|
||||
int tint2 = key.equals("tropical_fish") ? 0xFF3AB3DA : 0;
|
||||
EntityState s = new EntityState(key, 0, 0, 0, yaw, baby, 0.8, 1.0,
|
||||
isPlayer, null, false, VAR.get(key), tint, 1.0, PROF.get(key), LVL.getOrDefault(key, 0),
|
||||
MARK.get(key), SADDLE.contains(key), CHEST.contains(key), EQUIP.get(key), baby ? null : ARMOR.get(key),
|
||||
!baby && INVISIBLE.contains(key), 0, 0, tint2, false, null, null, null, 0, false, null);
|
||||
EntityState s = state(key, yaw);
|
||||
RenderedEntity re = baker.bake(s);
|
||||
if (re == null || re.cubes.isEmpty()) { // invisible with no equipment -> nothing renders
|
||||
return new BufferedImage(TW, TH, BufferedImage.TYPE_INT_RGB);
|
||||
@@ -208,6 +244,39 @@ public class EntityTestRender {
|
||||
return renderer.execute(job);
|
||||
}
|
||||
|
||||
/** Entity state for a case spec ({@code [baby:]type[@variant][+flag…]}, see VARIANT_CASES). */
|
||||
static EntityState state(String spec, float yaw) {
|
||||
boolean baby = spec.startsWith("baby:");
|
||||
if (baby) spec = spec.substring(5);
|
||||
String[] flagSplit = spec.split("\\+");
|
||||
Set<String> flags = new HashSet<>(Arrays.asList(flagSplit).subList(1, flagSplit.length));
|
||||
String key = flagSplit[0];
|
||||
String variant = null;
|
||||
if (key.contains("@")) {
|
||||
variant = key.substring(key.indexOf('@') + 1);
|
||||
key = key.substring(0, key.indexOf('@'));
|
||||
}
|
||||
boolean plain = flagSplit.length == 1 && variant == null; // default ENTITIES entry: legacy test setup
|
||||
if (variant == null) variant = VAR.get(key);
|
||||
boolean isPlayer = key.equals("player");
|
||||
int tint = key.equals("tropical_fish") ? 0xFFF9801D : (key.equals("sheep") ? 0xFFF9FFFE : 0);
|
||||
int tint2 = key.equals("tropical_fish") ? 0xFF3AB3DA : 0;
|
||||
EntityState.Equipment armor = plain ? (baby ? null : ARMOR.get(key)) : null;
|
||||
if (flags.contains("armor")) {
|
||||
EntityState.EquipPiece d = P("diamond");
|
||||
armor = new EntityState.Equipment(d, d, d, d);
|
||||
}
|
||||
boolean chest = plain ? CHEST.contains(key) : flags.contains("chest");
|
||||
boolean saddle = plain ? SADDLE.contains(key) : flags.contains("saddle");
|
||||
String equip = plain ? EQUIP.get(key) : null;
|
||||
boolean arms = flags.contains("arms");
|
||||
int collar = flags.contains("tame") ? 0xFFB02E26 : 0;
|
||||
return new EntityState(key, 0, 0, 0, yaw, baby, 0.8, 1.0,
|
||||
isPlayer, null, false, variant, tint, 1.0, PROF.get(key), LVL.getOrDefault(key, 0),
|
||||
plain ? MARK.get(key) : null, saddle, chest, arms, equip, armor,
|
||||
plain && !baby && INVISIBLE.contains(key), 0, 0, tint2, false, null, null, null, collar, false, null);
|
||||
}
|
||||
|
||||
static BufferedImage labelCell(String key, BufferedImage v1, BufferedImage v2) {
|
||||
int w = v1.getWidth() + v2.getWidth();
|
||||
int labelH = 20;
|
||||
|
||||
Reference in new issue
Block a user