From 0826e7ca50785bf23419cad2de2d30b2d8bb1e26 Mon Sep 17 00:00:00 2001 From: Vaern Date: Fri, 9 Sep 2022 22:39:32 -0700 Subject: [PATCH] fixed placedoor, shifted structure spawns and stuff --- .../hbm/world/worldgen/MapGenNTMFeatures.java | 28 ++++----- .../worldgen/components/CivilianFeatures.java | 3 +- .../world/worldgen/components/Feature.java | 57 ++++++++++++------- .../worldgen/components/OfficeFeatures.java | 11 +++- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/hbm/world/worldgen/MapGenNTMFeatures.java b/src/main/java/com/hbm/world/worldgen/MapGenNTMFeatures.java index 3308d46f3..7045891e0 100644 --- a/src/main/java/com/hbm/world/worldgen/MapGenNTMFeatures.java +++ b/src/main/java/com/hbm/world/worldgen/MapGenNTMFeatures.java @@ -109,7 +109,7 @@ public class MapGenNTMFeatures extends MapGenStructure { * Rainfall & Temperature Check */ //TODO: Do something about this so it's nice-looking and easily readable. Plus, test compatibility against mods like BoP - /*if(rand.nextBoolean()) { //Empty Ruin Structures + if(rand.nextBoolean()) { //Empty Ruin Structures switch(rand.nextInt(4)) { case 0: NTMRuin1 ruin1 = new NTMRuin1(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); @@ -137,30 +137,26 @@ public class MapGenNTMFeatures extends MapGenStructure { this.components.add(house2); } - } else if(biome.temperature >= 0.25 && biome.temperature <= 0.3 && biome.rainfall >= 0.6 && biome.rainfall <= 0.9) { //Taiga & Mega Taiga - if(rand.nextBoolean()) { + } else if(biome.temperature >= 0.25 && biome.temperature <= 0.3 && biome.rainfall >= 0.6 && biome.rainfall <= 0.9 && rand.nextBoolean()) { //Taiga & Mega Taiga NTMWorkshop1 workshop1 = new NTMWorkshop1(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); this.components.add(workshop1); - } - } else if(biome.heightVariation <= 0.2 && biome.rainfall <= 0.5 && !(biome instanceof BiomeGenBeach) && rand.nextBoolean()) { //Everything except jungles, extra-hilly areas, and beaches - if(rand.nextBoolean()) + } else if(biome.heightVariation <= 0.2 && biome.rainfall <= 0.5 && !(biome instanceof BiomeGenBeach) && rand.nextInt(3) == 0) { //Everything except jungles, extra-hilly areas, and beaches MilitaryBaseFeatures.smallHelipad(components, chunkX, posY, chunkZ, rand); //agggggggg - else {*/ - LargeOffice office = new LargeOffice(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); - this.components.add(office); - /*} } else { //Everything else - if(rand.nextBoolean()) { + switch(rand.nextInt(3)) { + case 0: NTMLab2 lab2 = new NTMLab2(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); - this.components.add(lab2); - } else { + this.components.add(lab2); break; + case 1: NTMLab1 lab1 = new NTMLab1(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); - this.components.add(lab1); + this.components.add(lab1); break; + case 2: + LargeOffice office = new LargeOffice(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); + this.components.add(office); break; } - - }*/ + } if(GeneralConfig.enableDebugMode) { System.out.print("[Debug] StructureStart at " + (chunkX * 16 + 8) + ", " + posY + ", " + (chunkZ * 16 + 8) + "\n[Debug] Components: "); diff --git a/src/main/java/com/hbm/world/worldgen/components/CivilianFeatures.java b/src/main/java/com/hbm/world/worldgen/components/CivilianFeatures.java index 88b2e9d9c..afcf72df3 100644 --- a/src/main/java/com/hbm/world/worldgen/components/CivilianFeatures.java +++ b/src/main/java/com/hbm/world/worldgen/components/CivilianFeatures.java @@ -330,11 +330,10 @@ public class CivilianFeatures { } } - int stairsMeta = this.getMetadataWithOffset(Blocks.stone_brick_stairs, 0); if(this.getBlockAtCurrentPosition(world, 2, 0, sizeZ - 1, box).getMaterial().isReplaceable() || this.getBlockAtCurrentPosition(world, 2, 0, sizeZ - 1, box) == Blocks.air) { this.func_151554_b(world, Blocks.stonebrick, 0, 2, -1, sizeZ - 1, box); - this.placeBlockAtCurrentPosition(world, Blocks.stone_brick_stairs, stairsMeta, 2, 0, sizeZ - 1, box); + this.placeBlockAtCurrentPosition(world, Blocks.stone_brick_stairs, getStairMeta(0), 2, 0, sizeZ - 1, box); } this.fillWithAir(world, box, 1, 0, 1, sizeX - 1, sizeY, 4); diff --git a/src/main/java/com/hbm/world/worldgen/components/Feature.java b/src/main/java/com/hbm/world/worldgen/components/Feature.java index f25d3a03e..d185fb4c3 100644 --- a/src/main/java/com/hbm/world/worldgen/components/Feature.java +++ b/src/main/java/com/hbm/world/worldgen/components/Feature.java @@ -183,14 +183,9 @@ abstract public class Feature extends StructureComponent { return metadata; } - //TODO: fix metadata finder for doors - //TODO: add method for stairs - /* For Later: - * 0/S: S->S; W->W; N->N; E->E - * 1/W: S->W; W->N; N->E; E->S - * 2/N: S->N; W->E; N->S; E->W - * 3/E: S->E; W->S; N->W; E->N - * 0/b00/W, 1/b01/E, 2/b10/N, 3/b11/S + /** + * Gets orientation-adjusted meta for stairs. + * 0 = West, 1 = East, 2 = North, 3 = South */ protected int getStairMeta(int metadata) { switch(this.coordBaseMode) { @@ -216,12 +211,29 @@ abstract public class Feature extends StructureComponent { return metadata; } + /* For Later: + * 0/S: S->S; W->W; N->N; E->E + * 1/W: S->W; W->N; N->E; E->S + * 2/N: S->N; W->E; N->S; E->W + * 3/E: S->E; W->S; N->W; E->N + * 0/b00/W, 1/b01/N, 2/b10/E, 3/b11/S + */ /** * Places door at specified location with orientation-adjusted meta * 0 = West, 1 = North, 2 = East, 3 = South */ - protected void placeDoor(World world, StructureBoundingBox box, Block door, int direction, int featureX, int featureY, int featureZ) { - int meta = getMetadataWithOffset(Blocks.wooden_door, direction); + protected void placeDoor(World world, StructureBoundingBox box, Block door, int meta, int featureX, int featureY, int featureZ) { + switch(this.coordBaseMode) { + default: + break; + case 1: + meta = (meta + 1) % 4; break; + case 2: + meta = meta ^ 2; break; //Flip second bit + case 3: + meta = (meta - 1) % 4; break; + } + int posX = this.getXWithOffset(featureX, featureZ); int posY = this.getYWithOffset(featureY); int posZ = this.getZWithOffset(featureX, featureZ); @@ -304,17 +316,22 @@ abstract public class Feature extends StructureComponent { /** * Places blocks underneath location until reaching a solid block; good for foundations */ - protected void placeFoundationUnderneath(World world, Block placeBlock, int meta, int featureX, int featureY, int featureZ, StructureBoundingBox box) { - int posX = this.getXWithOffset(featureX, featureZ); - int posY = this.getYWithOffset(featureY); - int posZ = this.getZWithOffset(featureX, featureZ); + protected void placeFoundationUnderneath(World world, Block placeBlock, int meta, int minX, int minZ, int maxX, int maxZ, int featureY, StructureBoundingBox box) { - if(box.isVecInside(posX, posY, posZ)) { - Block block = world.getBlock(posX, posY, posZ); - - while ((world.isAirBlock(posX, posY, posZ) || !block.getMaterial().isSolid() || (block.isFoliage(world, posX, posY, posZ) || block.getMaterial() == Material.leaves)) && posY > 1) { - world.setBlock(posX, posY, posZ, placeBlock, meta, 2); - block = world.getBlock(posX, --posY, posZ); + for(int featureX = minX; featureX <= maxX; featureX++) { + for(int featureZ = minZ; featureZ <= maxZ; featureZ++) { + int posX = this.getXWithOffset(featureX, featureZ); + int posY = this.getYWithOffset(featureY); + int posZ = this.getZWithOffset(featureX, featureZ); + + if(box.isVecInside(posX, posY, posZ)) { + Block block = world.getBlock(posX, posY, posZ); + + while ((world.isAirBlock(posX, posY, posZ) || !block.getMaterial().isSolid() || (block.isFoliage(world, posX, posY, posZ) || block.getMaterial() == Material.leaves)) && posY > 1) { + world.setBlock(posX, posY, posZ, placeBlock, meta, 2); + block = world.getBlock(posX, --posY, posZ); + } + } } } } diff --git a/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java b/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java index e4ce0f193..870f515a7 100644 --- a/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java +++ b/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java @@ -57,6 +57,11 @@ public class OfficeFeatures { this.boundingBox.offset(0, -1, 0); + placeFoundationUnderneath(world, Blocks.stonebrick, 0, 5, 0, sizeX, 1, -1, box); + placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 2, sizeX, 7, -1, box); + placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 8, 8, sizeZ, 0, box); + placeFoundationUnderneath(world, Blocks.stonebrick, 0, 9, 8, sizeX, sizeZ, -1, box); + //Pillars //Back fillWithBlocks(world, box, 0, 0, 2, 0, 4, 2, ModBlocks.concrete_pillar); @@ -79,7 +84,7 @@ public class OfficeFeatures { fillWithRandomizedBlocks(world, box, 6, 0, 0, sizeX - 1, 1, 0, rand, ConcreteBricks); fillWithRandomizedBlocks(world, box, 6, 2, 0, 6, 2, 0, rand, ConcreteBricks); fillWithRandomizedBlocks(world, box, 9, 2, 0, 10, 2, 0, rand, ConcreteBricks); - fillWithRandomizedBlocks(world, box, sizeX - 2, 2, 0, sizeX - 1, 2, 0, rand, ConcreteBricks); + fillWithRandomizedBlocks(world, box, sizeX - 1, 2, 0, sizeX - 1, 2, 0, rand, ConcreteBricks); fillWithRandomizedBlocks(world, box, 6, 3, 0, sizeX - 1, 4, 0, rand, ConcreteBricks); //Right fillWithRandomizedBlocks(world, box, sizeX, 0, 1, sizeX, 1, sizeZ - 1, rand, ConcreteBricks); @@ -188,6 +193,10 @@ public class OfficeFeatures { randomlyFillWithBlocks(world, box, rand, 0.25F, 1, 3, 3, 4, 3, 6, Blocks.web); randomlyFillWithBlocks(world, box, rand, 0.25F, 6, 3, 1, sizeX - 1, 3, 6, Blocks.web); randomlyFillWithBlocks(world, box, rand, 0.25F, 10, 3, 7, sizeX - 1, 3, sizeZ - 1, Blocks.web); + //Doors + placeDoor(world, box, ModBlocks.door_office, 3, 2, 1, 7); + placeDoor(world, box, ModBlocks.door_office, 3, 3, 1, 7); + placeDoor(world, box, ModBlocks.door_office, 0, 5, 1, 6); //Woot if(!this.hasPlacedLoot[0])