Skip to content

Commit

Permalink
Added more structures to level 0. :o
Browse files Browse the repository at this point in the history
  • Loading branch information
MegDuck committed Sep 17, 2024
1 parent 0f73e49 commit ca4dff4
Show file tree
Hide file tree
Showing 66 changed files with 30 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class LevelZeroChunkGenerator extends ChunkGenerator {
private static final int ROOF_BEGIN_Y = 6 * (getFloorCount() + 1) + 1;
private static final BlockState ROOF_BLOCK = BackroomsBlocks.BEDROCK_BRICKS.getDefaultState();

private final HashMap<String, NbtPlacerUtil> loadedStructures = new HashMap<String, NbtPlacerUtil>(30);
private final HashMap<String, NbtPlacerUtil> loadedStructures = new HashMap<String, NbtPlacerUtil>(100);
private final Identifier nbtId = BackroomsMod.id("level_zero");

private Random moldPlacementRandom;
Expand Down Expand Up @@ -109,6 +109,10 @@ public void buildSurface(ChunkRegion region, StructureAccessor structures, Noise
replace(BackroomsBlocks.RED_CARPETING, chunk, pos);
} else if(block == BackroomsBlocks.NOCLIP_WALL.getDefaultState()) {
replace(BackroomsBlocks.RED_PATTERNED_WALLPAPER, chunk, pos);
} else if(block == BackroomsBlocks.STRIPED_WALLPAPER.getDefaultState()) {
replace(BackroomsBlocks.RED_STRIPED_WALLPAPER, chunk, pos);
} else if(block == BackroomsBlocks.DOTTED_WALLPAPER.getDefaultState()) {
replace(BackroomsBlocks.RED_DOTTED_WALLPAPER, chunk, pos);
}
} else if (isBiomeEquals(BackroomsLevels.DECREPIT_BIOME, chunk, biomePos)) {
final BlockPos pos = chunkPos.getBlockPos(x, y, z);
Expand All @@ -120,6 +124,8 @@ public void buildSurface(ChunkRegion region, StructureAccessor structures, Noise
replace(BackroomsBlocks.REPAIRED_FLUORESCENT_LIGHT, chunk, pos);
} else if(block == BackroomsBlocks.NOCLIP_CARPETING.getDefaultState()) {
replace(BackroomsBlocks.MOLDY_WOOLEN_CARPET, chunk, pos);
} else if(block == Blocks.BIRCH_DOOR.getDefaultState()) {
replace(Blocks.DARK_OAK_DOOR, chunk, pos);
}
}
}
Expand Down Expand Up @@ -286,7 +292,7 @@ public CompletableFuture<Chunk> populateNoise(Executor executor, Blender blender
final int x = random.nextInt(16);
final int z = random.nextInt(16);
int x2 = x + random.nextInt(3) - 1;
int z2 = random.nextInt(3) - 1;
int z2 = z + random.nextInt(3) - 1;
if (chunk.getBlockState(new BlockPos(startX + x, 1 + 12 * y,
startZ + z)) == BackroomsBlocks.WOOLEN_CARPET.getDefaultState()) {
if (x2 < 0)
Expand Down Expand Up @@ -425,21 +431,15 @@ else if (z2 > 15)
// anyways.
// Place a large (7x7 or bigger) room in the current chunk at the current floor.
// Both dimensions of the base of the room must be of the form 4x-1.
if (random.nextFloat() < 0.1F || true) {
// Define the amounts of regular and nofill rooms.
final int regularRooms = 14;
final int nofillRooms = 4;
if (random.nextFloat() < 0.1f) {
// Define the amounts of r.egular and nofill rooms.
final int rooms = 58;
// Choose the room that will be placed.
int roomNumber = (random.nextInt(regularRooms + nofillRooms) + 1);
int roomNumber = (random.nextInt(1, rooms + 1));
// The number with an F directly after it denotes the probability of an empty
// room being generated regardless.
if (random.nextFloat() < 0.6F) {
roomNumber = 0;
}
String roomName = "backrooms_large_" + roomNumber;
if (roomNumber > regularRooms) {
roomName = "backrooms_large_nofill_" + (roomNumber - regularRooms);
}
// room being generated regardless;
String roomName = "room_" + roomNumber;

// Choose the rotation for the room.
Direction dir = Direction.fromHorizontal(random.nextInt(4));
BlockRotation rotation = switch (dir) {
Expand All @@ -450,8 +450,11 @@ else if (z2 > 15)
};

// Calculate size of current room


final var currentRoom = this.loadedStructures.get(roomName);


int sizeY = currentRoom.sizeY, sizeX, sizeZ;
final boolean isEastOrWestDirection = dir.equals(Direction.EAST) || dir.equals(Direction.WEST);
if (isEastOrWestDirection) {
Expand All @@ -464,37 +467,31 @@ else if (z2 > 15)
// Place a structure only if it fits before the bedrock
if (6 * y + sizeY < ROOF_BEGIN_Y) {
// Choose a spot in the chunk.
final int x = random.nextInt(5 - (sizeX + 1) / 4);
final int z = random.nextInt(5 - (sizeZ + 1) / 4);
final int x = random.nextInt(5);
final int z = random.nextInt(5);
// Fill the area the room will be placed in with air.
if (roomNumber <= regularRooms) {
for (int i = 0; i < sizeX; i++) {
for (int j = 0; j < sizeY; j++) {
for (int k = 0; k < sizeZ; k++) {
chunk.setBlockState(
new BlockPos(startX + x * 4 + i, 2 + 6 * y + j, startZ + z * 4 + k),
Blocks.AIR.getDefaultState(),
false);
}
for (int i = 0; i < sizeX; i++) {
for (int j = 0; j < sizeY; j++) {
for (int k = 0; k < sizeZ; k++) {
chunk.setBlockState(
new BlockPos(startX + x * 4 + i, 2 + 6 * y + j, startZ + z * 4 + k),
Blocks.AIR.getDefaultState(),
false);
}
}
}
generateNbt(chunk, new BlockPos(startX + x * 4, 2 + 6 * y, startZ + z * 4), roomName, rotation); // Actually
// generate
// the
// room.
generateNbt(chunk, new BlockPos(startX + x * 4, 2 + 6 * y, startZ + z * 4), roomName, rotation);
}
}
}

// Mold placement code; will be subject to heavy revisions, so ignore for now.
for (int y = getFloorCount(); y >= 0; y--) {

for (int i = 0; i < 300; i++) {
final int x = random.nextInt(16);
final int z = random.nextInt(16);
int x2 = x + random.nextInt(3) - 1;
int z2 = random.nextInt(3) - 1;
int z2 = z + random.nextInt(3) - 1;
if (chunk.getBlockState(new BlockPos(startX + x, 1 + 6 * y,
startZ + z)) == BackroomsBlocks.WOOLEN_CARPET.getDefaultState()) {
if (x2 < 0)
Expand Down Expand Up @@ -556,9 +553,7 @@ public static int getFloorCount() {
}

public void storeStructures(ServerWorld world) {
store("backrooms_large", world, 0, 14); // Makes it so the large regular rooms can be used while generating.
store("backrooms_large_nofill", world, 1, 4); // Makes it so the large nofill rooms can be used while
// generating.
store("room", world, 1, 58);
}

private void store(String id, ServerWorld world) {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit ca4dff4

Please sign in to comment.