fix(UC-02): arch review — furniture x/z offsets + ceiling chain fidelity
- Add x_offset/z_offset to PositionedBlock for multi-block furniture clusters - Furniture items now spread across 2-3 positions (matching original Java code) - Offsets multiplied by inward direction for correct corner orientation - Fix has_ceiling_chain: only oubliette has ceiling chains (was true for all 6) - Fix firstCornerSpecial: oubliette cauldron uses x/z offset +1 (inward diagonal) - Update parser to read x_offset/z_offset (defaults to 0)
This commit is contained in:
@@ -27,10 +27,17 @@ public record DecorationConfig(
|
||||
) {
|
||||
|
||||
/**
|
||||
* A block state with an associated Y offset for positioned placement.
|
||||
* A block state with positional offsets for placement.
|
||||
*
|
||||
* @param state the block state to place
|
||||
* @param xOffset horizontal X offset from base position (0 = no offset)
|
||||
* @param yOffset vertical offset from the base position
|
||||
* @param zOffset horizontal Z offset from base position (0 = no offset)
|
||||
*/
|
||||
public record PositionedBlock(BlockState state, int yOffset) {}
|
||||
public record PositionedBlock(BlockState state, int xOffset, int yOffset, int zOffset) {
|
||||
/** Convenience constructor for Y-offset-only blocks (most common case). */
|
||||
public PositionedBlock(BlockState state, int yOffset) {
|
||||
this(state, 0, yOffset, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,24 +660,35 @@ public class HangingCagePiece extends StructurePiece {
|
||||
}
|
||||
|
||||
// First corner special (e.g. water cauldron, skull, TNT, sculk catalyst)
|
||||
// x/z offsets are multiplied by inward direction (toward room center)
|
||||
if (deco.firstCornerSpecial() != null && corners.length > 0) {
|
||||
int[] sc = corners[0];
|
||||
if (layout.isInShape(sc[0], sc[1]) && !layout.isWall(sc[0], sc[1])) {
|
||||
int dirX = sc[0] < 6 ? 1 : -1;
|
||||
int dirZ = sc[1] < 6 ? 1 : -1;
|
||||
int scx = sc[0] + deco.firstCornerSpecial().xOffset() * dirX;
|
||||
int scz = sc[1] + deco.firstCornerSpecial().zOffset() * dirZ;
|
||||
if (layout.isInShape(scx, scz) && !layout.isWall(scx, scz)) {
|
||||
safeSetBlock(level,
|
||||
new BlockPos(baseX + sc[0], floorY + deco.firstCornerSpecial().yOffset(), baseZ + sc[1]),
|
||||
new BlockPos(baseX + scx, floorY + deco.firstCornerSpecial().yOffset(), baseZ + scz),
|
||||
deco.firstCornerSpecial().state(), chunkBB);
|
||||
}
|
||||
}
|
||||
|
||||
// Furniture cluster at corners[1] (e.g. barrel+brewing_stand, soul_campfire+cauldron)
|
||||
// Furniture cluster at corners[1] — each item has x/z offsets relative to the
|
||||
// base furniture position. x_offset/z_offset values are multiplied by the
|
||||
// inward direction (toward room center) to handle all 4 corner orientations.
|
||||
if (corners.length > 1) {
|
||||
int[] fc = corners[1];
|
||||
int fcx = fc[0] + (fc[0] < 6 ? 1 : -1);
|
||||
int fcz = fc[1] + (fc[1] < 6 ? 1 : -1);
|
||||
if (layout.isInShape(fcx, fcz) && !layout.isWall(fcx, fcz)) {
|
||||
for (DecorationConfig.PositionedBlock pb : deco.furnitureCluster()) {
|
||||
int dirX = fc[0] < 6 ? 1 : -1;
|
||||
int dirZ = fc[1] < 6 ? 1 : -1;
|
||||
int fcx = fc[0] + dirX;
|
||||
int fcz = fc[1] + dirZ;
|
||||
for (DecorationConfig.PositionedBlock pb : deco.furnitureCluster()) {
|
||||
int px = fcx + pb.xOffset() * dirX;
|
||||
int pz = fcz + pb.zOffset() * dirZ;
|
||||
if (layout.isInShape(px, pz) && !layout.isWall(px, pz)) {
|
||||
safeSetBlock(level,
|
||||
new BlockPos(baseX + fcx, floorY + pb.yOffset(), baseZ + fcz),
|
||||
new BlockPos(baseX + px, floorY + pb.yOffset(), baseZ + pz),
|
||||
pb.state(), chunkBB);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ public final class RoomThemeParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single positioned block: { "block": "...", "y_offset": 0 }
|
||||
* Parse a single positioned block: { "block": "...", "x_offset": 0, "y_offset": 0, "z_offset": 0 }
|
||||
*/
|
||||
@Nullable
|
||||
private static DecorationConfig.PositionedBlock parsePositionedBlock(
|
||||
@@ -445,8 +445,10 @@ public final class RoomThemeParser {
|
||||
BlockState state = parseBlockState(blockStr, fileId);
|
||||
if (state == null) return null;
|
||||
|
||||
int xOffset = getIntOrDefault(obj, "x_offset", 0);
|
||||
int yOffset = getIntOrDefault(obj, "y_offset", 0);
|
||||
return new DecorationConfig.PositionedBlock(state, yOffset);
|
||||
int zOffset = getIntOrDefault(obj, "z_offset", 0);
|
||||
return new DecorationConfig.PositionedBlock(state, xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
// ===== Primitive Helpers =====
|
||||
|
||||
Reference in New Issue
Block a user