made strucutres better
This commit is contained in:
parent
bfd39cd54b
commit
068feb0d4d
@ -1,5 +1,6 @@
|
|||||||
package net.Chipperfluff.chipi.world.gen;
|
package net.Chipperfluff.chipi.world.gen;
|
||||||
|
|
||||||
|
import net.Chipperfluff.chipi.world.gen.struct.CorridorEWStructure;
|
||||||
import net.Chipperfluff.chipi.world.gen.struct.CorridorNSStructure;
|
import net.Chipperfluff.chipi.world.gen.struct.CorridorNSStructure;
|
||||||
import net.Chipperfluff.chipi.world.gen.struct.RoomBaseStructure;
|
import net.Chipperfluff.chipi.world.gen.struct.RoomBaseStructure;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@ -15,6 +16,8 @@ public class ChipiDungeonGenerator {
|
|||||||
// Structure extents from NBT sizes (centered)
|
// Structure extents from NBT sizes (centered)
|
||||||
private static final int ROOM_EXTENT_SOUTH = 8;
|
private static final int ROOM_EXTENT_SOUTH = 8;
|
||||||
private static final int ROOM_EXTENT_NORTH = 8;
|
private static final int ROOM_EXTENT_NORTH = 8;
|
||||||
|
private static final int ROOM_EXTENT_EAST = 7;
|
||||||
|
private static final int ROOM_EXTENT_WEST = 9;
|
||||||
|
|
||||||
// Fixed Y-levels
|
// Fixed Y-levels
|
||||||
private static final int ROOM_Y = 89;
|
private static final int ROOM_Y = 89;
|
||||||
@ -25,7 +28,7 @@ public class ChipiDungeonGenerator {
|
|||||||
|
|
||||||
// Center-to-center step so corridors start 1 block inside the north room and end 1 block inside the south room.
|
// Center-to-center step so corridors start 1 block inside the north room and end 1 block inside the south room.
|
||||||
private static final int STEP_Z = ROOM_EXTENT_SOUTH + CORRIDOR_LENGTH + ROOM_EXTENT_NORTH - 1; // 25
|
private static final int STEP_Z = ROOM_EXTENT_SOUTH + CORRIDOR_LENGTH + ROOM_EXTENT_NORTH - 1; // 25
|
||||||
private static final int STEP_X = STEP_Z; // symmetric spacing on X
|
private static final int STEP_X = ROOM_EXTENT_EAST + CORRIDOR_LENGTH + ROOM_EXTENT_WEST - 1; // 25
|
||||||
|
|
||||||
private static final int ROWS_SOUTH = 40; // rows of rooms south of spawn (spawn room itself is already placed)
|
private static final int ROWS_SOUTH = 40; // rows of rooms south of spawn (spawn room itself is already placed)
|
||||||
private static final int COLS_EW = 40; // columns across X (split roughly evenly around center)
|
private static final int COLS_EW = 40; // columns across X (split roughly evenly around center)
|
||||||
@ -38,6 +41,10 @@ public class ChipiDungeonGenerator {
|
|||||||
return new CorridorNSStructure();
|
return new CorridorNSStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static CorridorEWStructure getTunnelEW() {
|
||||||
|
return new CorridorEWStructure();
|
||||||
|
}
|
||||||
|
|
||||||
private ChipiDungeonGenerator() {}
|
private ChipiDungeonGenerator() {}
|
||||||
|
|
||||||
public static void generateInitialLayout(ServerWorld world, BlockPos portalSpawnPos) {
|
public static void generateInitialLayout(ServerWorld world, BlockPos portalSpawnPos) {
|
||||||
@ -53,6 +60,7 @@ public class ChipiDungeonGenerator {
|
|||||||
|
|
||||||
RoomBaseStructure room = getRoom();
|
RoomBaseStructure room = getRoom();
|
||||||
CorridorNSStructure corridorNS = getTunnelNS();
|
CorridorNSStructure corridorNS = getTunnelNS();
|
||||||
|
CorridorEWStructure corridorEW = getTunnelEW();
|
||||||
|
|
||||||
// Place the first room (absolute coordinates).
|
// Place the first room (absolute coordinates).
|
||||||
firstRoom.placeAt(world, firstGeneratedRoomCenter);
|
firstRoom.placeAt(world, firstGeneratedRoomCenter);
|
||||||
@ -95,6 +103,25 @@ public class ChipiDungeonGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connect east-west neighbors in each row.
|
||||||
|
for (int row = 0; row < ROWS_SOUTH; row++) {
|
||||||
|
for (int col = minCol; col < maxCol; col++) {
|
||||||
|
BlockPos currentCenter = new BlockPos(
|
||||||
|
firstGeneratedRoomCenter.getX() + (col * STEP_X),
|
||||||
|
ROOM_Y,
|
||||||
|
firstGeneratedRoomCenter.getZ() + (row * STEP_Z)
|
||||||
|
);
|
||||||
|
|
||||||
|
BlockPos anchorEast = new BlockPos(
|
||||||
|
currentCenter.getX() + ROOM_EXTENT_EAST,
|
||||||
|
CORRIDOR_Y,
|
||||||
|
currentCenter.getZ()
|
||||||
|
);
|
||||||
|
|
||||||
|
corridorEW.placeAt(world, anchorEast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanUpEntrance(world);
|
cleanUpEntrance(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public abstract class ChipiStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Pure structure placement */
|
/** Pure structure placement */
|
||||||
public void placeAt(ServerWorld world, BlockPos origin) {
|
public void placeAt(ServerWorld world, BlockPos centerPos) {
|
||||||
Optional<StructureTemplate> opt =
|
Optional<StructureTemplate> opt =
|
||||||
world.getStructureTemplateManager().getTemplate(id);
|
world.getStructureTemplateManager().getTemplate(id);
|
||||||
|
|
||||||
@ -49,6 +49,10 @@ public abstract class ChipiStructure {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockPos origin = centerPos.add(
|
||||||
|
new BlockPos(deltaX, deltaY, deltaZ)
|
||||||
|
);
|
||||||
|
|
||||||
StructureTemplate template = opt.get();
|
StructureTemplate template = opt.get();
|
||||||
|
|
||||||
template.place(
|
template.place(
|
||||||
@ -64,13 +68,12 @@ public abstract class ChipiStructure {
|
|||||||
/** Command placement (structure + optional marker) */
|
/** Command placement (structure + optional marker) */
|
||||||
public void placeCommand(ServerWorld world, BlockPos placePos, boolean marker) {
|
public void placeCommand(ServerWorld world, BlockPos placePos, boolean marker) {
|
||||||
|
|
||||||
|
placeAt(world, placePos);
|
||||||
|
|
||||||
BlockPos origin = placePos.add(
|
BlockPos origin = placePos.add(
|
||||||
new BlockPos(deltaX, deltaY, deltaZ)
|
new BlockPos(deltaX, deltaY, deltaZ)
|
||||||
);
|
);
|
||||||
|
|
||||||
placeAt(world, origin);
|
|
||||||
|
|
||||||
if (!marker) return;
|
if (!marker) return;
|
||||||
|
|
||||||
world.setBlockState(origin, Blocks.STRUCTURE_BLOCK.getDefaultState(), 3);
|
world.setBlockState(origin, Blocks.STRUCTURE_BLOCK.getDefaultState(), 3);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user