render chests from the dumped vanilla models (single, double, trapped, ender, copper)
This commit is contained in:
1 parent
9a6c8b538d
commit
5852d4b367
7 files changed
+161
-21
No files matched your search
@@ -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);
|
||||
|
||||
@@ -56,6 +56,11 @@ public class PPTest extends JavaPlugin {
|
||||
scenes.put("pistondown", new Scene("pistondown", this::piston, -1.6, 2.6, -1.6, 0.5, 1.4, 0.5));
|
||||
scenes.put("pistonup", new Scene("pistonup", this::piston, 0.4, 2.6, -1.6, 2.5, 1.4, 0.5));
|
||||
scenes.put("vehicles", new Scene("vehicles", this::vehicles, 5, 3, -7, 5, 0.6, 1.5));
|
||||
// Chests: same layout seen from all four sides (single/double per facing, trapped, ender, copper).
|
||||
scenes.put("chests_s", new Scene("chests_s", this::chests, 4.5, 5, 13, 4.5, 0, 3));
|
||||
scenes.put("chests_n", new Scene("chests_n", this::chests, 4.5, 5, -7, 4.5, 0, 3));
|
||||
scenes.put("chests_e", new Scene("chests_e", this::chests, 16, 5, 3, 4.5, 0, 3));
|
||||
scenes.put("chests_w", new Scene("chests_w", this::chests, -7, 5, 3, 4.5, 0, 3));
|
||||
scenes.put("translucent", new Scene("translucent", this::translucent, 4.5, 2.8, -5.5, 4.5, 0.8, 2));
|
||||
}
|
||||
|
||||
@@ -430,6 +435,29 @@ public class PPTest extends JavaPlugin {
|
||||
o.clone().add(9, 0, 4).getBlock().setBlockData(Bukkit.createBlockData("minecraft:oak_log[axis=z]"), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Row z=0: single chests facing S/W/N/E (x=0,3,6,9). Row z=3: double chests per facing — the LEFT half
|
||||
* at x, its RIGHT partner on facing.getClockWise(). Row z=6: trapped double (S), ender, copper, oxidized
|
||||
* copper double (N).
|
||||
*/
|
||||
private void chests(Location o) {
|
||||
String[] f = {"south", "west", "north", "east"};
|
||||
int[][] cw = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
|
||||
java.util.function.BiConsumer<int[], String> put = (p, data) -> o.clone().add(p[0], p[1], p[2]).getBlock()
|
||||
.setBlockData(Bukkit.createBlockData("minecraft:" + data), false);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
put.accept(new int[] {i * 3, 0, 0}, "chest[facing=" + f[i] + ",type=single]");
|
||||
put.accept(new int[] {i * 3, 0, 3}, "chest[facing=" + f[i] + ",type=left]");
|
||||
put.accept(new int[] {i * 3 + cw[i][0], 0, 3 + cw[i][1]}, "chest[facing=" + f[i] + ",type=right]");
|
||||
}
|
||||
put.accept(new int[] {0, 0, 6}, "trapped_chest[facing=south,type=left]");
|
||||
put.accept(new int[] {-1, 0, 6}, "trapped_chest[facing=south,type=right]");
|
||||
put.accept(new int[] {3, 0, 6}, "ender_chest[facing=south]");
|
||||
put.accept(new int[] {6, 0, 6}, "copper_chest[facing=east,type=single]");
|
||||
put.accept(new int[] {9, 0, 6}, "oxidized_copper_chest[facing=north,type=left]");
|
||||
put.accept(new int[] {10, 0, 6}, "oxidized_copper_chest[facing=north,type=right]");
|
||||
}
|
||||
|
||||
/** Redstone wire (dot, line, corner, climbing a wall, powered/unpowered) next to glass and panes. */
|
||||
private void redstone(Location o) {
|
||||
java.util.function.BiConsumer<int[], String> put = (p, data) -> o.clone().add(p[0], p[1], p[2]).getBlock()
|
||||
|
||||
Reference in new issue
Block a user