kinda fixed
This commit is contained in:
parent
dd5060b68d
commit
1c7d72d721
@ -7,39 +7,67 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ChipiDungeonGenerator {
|
||||
|
||||
// Structure extents from NBT sizes (centered)
|
||||
private static final int ROOM_EXTENT_SOUTH = 8;
|
||||
private static final int ROOM_EXTENT_NORTH = 8;
|
||||
|
||||
// Fixed Y-levels
|
||||
private static final int ROOM_Y = 88;
|
||||
private static final int CORRIDOR_Y = 89;
|
||||
|
||||
// Corridors are 10 long; place them with a 1-block gap from room walls (-1 overlap into each room)
|
||||
private static final int GAP_TO_CORRIDOR = 1;
|
||||
private static final int CORRIDOR_LENGTH = 10;
|
||||
|
||||
// Center-to-center step so corridors start 1 block after the room wall and end 1 block before the next
|
||||
private static final int STEP_Z = ROOM_EXTENT_SOUTH + GAP_TO_CORRIDOR + CORRIDOR_LENGTH + ROOM_EXTENT_NORTH; // 27
|
||||
|
||||
private static final int ROWS_SOUTH = 40; // total rooms including the first fixed one
|
||||
|
||||
private static RoomBaseStructure getRoom() {
|
||||
return new RoomBaseStructure();
|
||||
}
|
||||
|
||||
private static CorridorNSStructure getTunnelNS() {
|
||||
return new CorridorNSStructure();
|
||||
}
|
||||
|
||||
private ChipiDungeonGenerator() {}
|
||||
|
||||
public static void generateInitialLayout(ServerWorld world, BlockPos portalSpawnPos) {
|
||||
|
||||
// Y is constant – dungeon is 2D
|
||||
BlockPos center = new BlockPos(
|
||||
portalSpawnPos.getX(),
|
||||
portalSpawnPos.getY(),
|
||||
portalSpawnPos.getZ()
|
||||
);
|
||||
// Fixed anchors (not relative to portal): first corridor then the first room.
|
||||
BlockPos firstCorridorAnchor = new BlockPos(5, CORRIDOR_Y, 11);
|
||||
BlockPos firstRoomCenter = new BlockPos(5, ROOM_Y, 11);
|
||||
|
||||
// 1️⃣ FIRST ROOM (THIS IS THE CENTER)
|
||||
RoomBaseStructure room = new RoomBaseStructure();
|
||||
RoomBaseStructure room = getRoom();
|
||||
CorridorNSStructure corridorNS = getTunnelNS();
|
||||
|
||||
// Place the fixed corridor and first room.
|
||||
corridorNS.place(world, firstCorridorAnchor);
|
||||
room.place(world, firstRoomCenter);
|
||||
|
||||
// Place remaining rooms strictly southward (Z never decreases).
|
||||
for (int row = 1; row < ROWS_SOUTH; row++) {
|
||||
BlockPos center = firstRoomCenter.add(
|
||||
0,
|
||||
0,
|
||||
row * STEP_Z
|
||||
);
|
||||
room.place(world, center);
|
||||
}
|
||||
|
||||
// 2️⃣ SOUTH CORRIDOR (NO CENTER, JUST OFFSET)
|
||||
CorridorNSStructure corridor = new CorridorNSStructure();
|
||||
// Connect each room to the next one south with a corridor at fixed Y.
|
||||
for (int row = 0; row < ROWS_SOUTH - 1; row++) {
|
||||
BlockPos currentCenter = firstRoomCenter.add(0, 0, row * STEP_Z);
|
||||
|
||||
BlockPos corridorAnchor = center.add(
|
||||
0,
|
||||
0,
|
||||
9 // room south edge + 1
|
||||
BlockPos anchorSouth = new BlockPos(
|
||||
currentCenter.getX(),
|
||||
CORRIDOR_Y,
|
||||
currentCenter.getZ() + ROOM_EXTENT_SOUTH + GAP_TO_CORRIDOR
|
||||
);
|
||||
|
||||
corridor.place(world, corridorAnchor);
|
||||
|
||||
// 3️⃣ SECOND ROOM AT END OF CORRIDOR
|
||||
BlockPos secondRoomCenter = corridorAnchor.add(
|
||||
0,
|
||||
0,
|
||||
10 // full corridor length
|
||||
);
|
||||
|
||||
room.place(world, secondRoomCenter);
|
||||
corridorNS.place(world, anchorSouth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user