kinda fixed

This commit is contained in:
Chipperfluff 2025-12-16 09:47:53 +01:00
parent dd5060b68d
commit 1c7d72d721

View File

@ -7,39 +7,67 @@ import net.minecraft.util.math.BlockPos;
public class ChipiDungeonGenerator { 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() {} private ChipiDungeonGenerator() {}
public static void generateInitialLayout(ServerWorld world, BlockPos portalSpawnPos) { public static void generateInitialLayout(ServerWorld world, BlockPos portalSpawnPos) {
// Y is constant dungeon is 2D // Fixed anchors (not relative to portal): first corridor then the first room.
BlockPos center = new BlockPos( BlockPos firstCorridorAnchor = new BlockPos(5, CORRIDOR_Y, 11);
portalSpawnPos.getX(), BlockPos firstRoomCenter = new BlockPos(5, ROOM_Y, 11);
portalSpawnPos.getY(),
portalSpawnPos.getZ()
);
// 1 FIRST ROOM (THIS IS THE CENTER) RoomBaseStructure room = getRoom();
RoomBaseStructure room = new RoomBaseStructure(); 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); room.place(world, center);
}
// 2 SOUTH CORRIDOR (NO CENTER, JUST OFFSET) // Connect each room to the next one south with a corridor at fixed Y.
CorridorNSStructure corridor = new CorridorNSStructure(); for (int row = 0; row < ROWS_SOUTH - 1; row++) {
BlockPos currentCenter = firstRoomCenter.add(0, 0, row * STEP_Z);
BlockPos corridorAnchor = center.add( BlockPos anchorSouth = new BlockPos(
0, currentCenter.getX(),
0, CORRIDOR_Y,
9 // room south edge + 1 currentCenter.getZ() + ROOM_EXTENT_SOUTH + GAP_TO_CORRIDOR
); );
corridor.place(world, corridorAnchor); corridorNS.place(world, anchorSouth);
}
// 3 SECOND ROOM AT END OF CORRIDOR
BlockPos secondRoomCenter = corridorAnchor.add(
0,
0,
10 // full corridor length
);
room.place(world, secondRoomCenter);
} }
} }