render chests from the dumped vanilla models (single, double, trapped, ender, copper)

This commit is contained in:
MineTec committed 2026-11-04 13:57:35 +01:00
1 parent 9a6c8b538d
commit 5852d4b367
7 files changed
+161 -21

No files matched your search

+42 -9
View File
@@ -86,13 +86,33 @@ public class BlockEntityTestRender {
// Scenes: label -> list of block-entity states.
LinkedHashMap<String, List<BlockEntityState>> scenes = new LinkedHashMap<>();
scenes.put("chest_S", List.of(be(Kind.CHEST, 0, 0, 0, 0)));
scenes.put("chest_N", List.of(be(Kind.CHEST, 0, 0, 0, 180)));
scenes.put("chest_E", List.of(be(Kind.CHEST, 0, 0, 0, 270)));
scenes.put("chest_W", List.of(be(Kind.CHEST, 0, 0, 0, 90)));
scenes.put("double_chest", List.of(
new BlockEntityState(Kind.CHEST, 0, 0, 0, 0, ChestKind.LEFT, 0, null, null, null, null, null, List.of(), List.of(), null, null, null),
new BlockEntityState(Kind.CHEST, 1, 0, 0, 0, ChestKind.RIGHT, 0, null, null, null, null, null, List.of(), List.of(), null, null, null)));
// Chests: single + double (all four facings), trapped/ender/copper. A double chest's LEFT half has
// its partner (RIGHT) on facing.getClockWise(): S→west, W→north, N→east, E→south.
String[] dirs = {"S", "W", "N", "E"};
int[][] partner = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
for (int i = 0; i < 4; i++) {
float yaw = i * 90;
scenes.put("chest_" + dirs[i], List.of(chest(Kind.CHEST, 0, 0, yaw, ChestKind.SINGLE, null)));
frontCam.put("chest_" + dirs[i], yaw);
scenes.put("double_chest_" + dirs[i], List.of(
chest(Kind.CHEST, 0, 0, yaw, ChestKind.LEFT, null),
chest(Kind.CHEST, partner[i][0], partner[i][1], yaw, ChestKind.RIGHT, null)));
frontCam.put("double_chest_" + dirs[i], yaw);
}
scenes.put("double_chest_back", scenes.get("double_chest_S"));
frontCam.put("double_chest_back", 180f);
scenes.put("trapped_double", List.of(
chest(Kind.TRAPPED_CHEST, 0, 0, 0, ChestKind.LEFT, null),
chest(Kind.TRAPPED_CHEST, -1, 0, 0, ChestKind.RIGHT, null)));
frontCam.put("trapped_double", 0f);
scenes.put("ender_chest", List.of(chest(Kind.ENDER_CHEST, 0, 0, 0, ChestKind.SINGLE, null)));
frontCam.put("ender_chest", 0f);
scenes.put("copper_chest", List.of(chest(Kind.COPPER_CHEST, 0, 0, 0, ChestKind.SINGLE, null)));
frontCam.put("copper_chest", 0f);
scenes.put("copper_oxidized_double", List.of(
chest(Kind.COPPER_CHEST, 0, 0, 0, ChestKind.LEFT, "oxidized"),
chest(Kind.COPPER_CHEST, -1, 0, 0, ChestKind.RIGHT, "oxidized")));
frontCam.put("copper_oxidized_double", 0f);
scenes.put("sign", List.of(be(Kind.SIGN, 0, 0, 0, 0)));
scenes.put("wall_sign", List.of(be(Kind.WALL_SIGN, 0, 0, 0, 0)));
scenes.put("hanging_sign", List.of(be(Kind.HANGING_SIGN, 0, 0, 0, 0)));
@@ -156,7 +176,7 @@ public class BlockEntityTestRender {
List<BufferedImage> cells = new ArrayList<>();
List<String> names = new ArrayList<>(scenes.keySet());
for (String name : names) {
cells.add(labelCell(name, renderScene(renderer, empty, sky, scenes.get(name))));
cells.add(labelCell(name, renderScene(renderer, empty, sky, scenes.get(name), frontCam.get(name))));
log.info("rendered " + name);
}
for (String name : decoScenes.keySet()) {
@@ -182,13 +202,21 @@ public class BlockEntityTestRender {
System.out.println("WROTE " + f);
}
/** Scenes viewed from the front (camera along the facing yaw, raised, slightly to the side). */
static final Map<String, Float> frontCam = new HashMap<>();
static BlockEntityState chest(Kind kind, int bx, int bz, float yaw, ChestKind ck, String variant) {
return new BlockEntityState(kind, bx, 0, bz, yaw, ck, 0, variant, null, null, null, null,
List.of(), List.of(), null, null, null);
}
static BlockEntityState head(String type) { return headKind(Kind.HEAD, type); }
static BlockEntityState headKind(Kind kind, String type) {
return new BlockEntityState(kind, 0, 0, 0, 0, null, 0, null, null, null, type, null, List.of(), List.of(), null, null, null);
}
static BufferedImage renderScene(DefaultScreenRenderer renderer, WorldSnapshot world, SkyContext sky,
List<BlockEntityState> states) {
List<BlockEntityState> states, Float frontYaw) {
double[] min = {Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE};
double[] max = {-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE};
for (BlockEntityState s : states) {
@@ -204,6 +232,11 @@ public class BlockEntityTestRender {
Vector center = new Vector(cx, cy, cz);
Vector cam = new Vector(cx - dist, cy + dist * 0.45, cz - dist * 0.35);
if (frontYaw != null) {
// Facing yaw (0 = south, 90 = west) → front direction (-sin, cos); offset 25° to the side.
double a = Math.toRadians(frontYaw + 25);
cam = new Vector(cx - Math.sin(a) * dist, cy + dist * 0.55, cz + Math.cos(a) * dist);
}
Location loc = new Location(null, cam.getX(), cam.getY(), cam.getZ());
loc.setDirection(center.clone().subtract(cam));
List<Vector> rayMap = buildRayMap(loc, TW * SSAA, TH * SSAA);