diff --git a/src/main/java/com/hbm/main/StructureManager.java b/src/main/java/com/hbm/main/StructureManager.java index 2456533ff..d7881ba66 100644 --- a/src/main/java/com/hbm/main/StructureManager.java +++ b/src/main/java/com/hbm/main/StructureManager.java @@ -48,6 +48,7 @@ public class StructureManager { public static final NBTStructure meteor_dragon_tesla = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/meteor/room10/headloot/loot-tesla.nbt")); public static final NBTStructure meteor_dragon_trap = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/meteor/room10/headloot/loot-trap.nbt")); public static final NBTStructure meteor_dragon_crate_crab = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/meteor/room10/headloot/loot-crate-crab.nbt")); + public static final NBTStructure meteor_dragon_fallback = new NBTStructure(new ResourceLocation(RefStrings.MODID, "structures/meteor/room10/headloot/loot-fallback.nbt")); diff --git a/src/main/java/com/hbm/world/gen/NBTStructure.java b/src/main/java/com/hbm/world/gen/NBTStructure.java index 43625a627..6ec619378 100644 --- a/src/main/java/com/hbm/world/gen/NBTStructure.java +++ b/src/main/java/com/hbm/world/gen/NBTStructure.java @@ -650,6 +650,10 @@ public class NBTStructure { // Maximum amount of components in this structure public int sizeLimit = 8; + // How far the structure can extend horizontally from the center, maximum of 128 + // This could be increased by changing GenStructure:range from 8, but this is already quite reasonably large + public int rangeLimit = 128; + // Height modifiers, will clamp height that the start generates at, allowing for: // * Submarines that must spawn under the ocean surface // * Bunkers that sit underneath the ground @@ -967,7 +971,8 @@ public class NBTStructure { if(fromComponent.piece.structure.fromConnections == null) continue; - boolean fallbacksOnly = this.components.size() >= spawn.sizeLimit; + int distance = getDistanceTo(fromComponent.getBoundingBox()); + boolean fallbacksOnly = this.components.size() >= spawn.sizeLimit || distance >= spawn.rangeLimit; for(List unshuffledList : fromComponent.piece.structure.fromConnections) { List connectionList = new ArrayList<>(unshuffledList); @@ -1013,7 +1018,7 @@ public class NBTStructure { } if(GeneralConfig.enableDebugMode) { - MainRegistry.logger.info("[Debug] Spawning NBT structure at: " + chunkX * 16 + ", " + chunkZ * 16); + MainRegistry.logger.info("[Debug] Spawning NBT structure with " + components.size() + " piece(s) at: " + chunkX * 16 + ", " + chunkZ * 16); String componentList = "[Debug] Components: "; for(Object component : this.components) { componentList += ((Component) component).piece.structure.name + " "; @@ -1070,6 +1075,13 @@ public class NBTStructure { return nextPiece.structure.toHorizontalConnections.get(fromConnection.targetName); } + private int getDistanceTo(StructureBoundingBox box) { + int x = box.getCenterX(); + int z = box.getCenterZ(); + + return Math.max(Math.abs(x - (func_143019_e() << 4)), Math.abs(z - (func_143018_f() << 4))); + } + // post loading, update parent reference for loaded components @Override public void func_143017_b(NBTTagCompound nbt) { @@ -1152,4 +1164,4 @@ public class NBTStructure { } -} \ No newline at end of file +} diff --git a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java index 3d9306b28..f68921cb3 100644 --- a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java +++ b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java @@ -50,23 +50,23 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); Map bricks = new HashMap() {{ - put(ModBlocks.meteor_brick, new MeteorBricks()); - }}; - Map crates = new HashMap() {{ - put(ModBlocks.meteor_brick, new MeteorBricks()); - put(ModBlocks.crate, new SupplyCrates()); - put(ModBlocks.meteor_spawner, new CrabSpawners()); - }}; - Map ooze = new HashMap() {{ - put(ModBlocks.meteor_brick, new MeteorBricks()); - put(ModBlocks.concrete_colored, new GreenOoze()); - }}; + put(ModBlocks.meteor_brick, new MeteorBricks()); + }}; + Map crates = new HashMap() {{ + put(ModBlocks.meteor_brick, new MeteorBricks()); + put(ModBlocks.crate, new SupplyCrates()); + put(ModBlocks.meteor_spawner, new CrabSpawners()); + }}; + Map ooze = new HashMap() {{ + put(ModBlocks.meteor_brick, new MeteorBricks()); + put(ModBlocks.concrete_colored, new GreenOoze()); + }}; - NBTStructure.registerStructure(0, new SpawnCondition() {{ + NBTStructure.registerStructure(0, new SpawnCondition() {{ minHeight = 32; maxHeight = 32; sizeLimit = 128; - canSpawn = biome -> biome.rootHeight >= 0; + canSpawn = biome -> biome.rootHeight >= 0; startPool = "start"; pools = new HashMap() {{ put("start", new JigsawPool() {{ @@ -116,6 +116,7 @@ public class NTMWorldGenerator implements IWorldGenerator { add(new JigsawPiece("meteor_dragon_tesla", StructureManager.meteor_dragon_tesla) {{ blockTable = crates; }}, 1); add(new JigsawPiece("meteor_dragon_trap", StructureManager.meteor_dragon_trap) {{ blockTable = crates; }}, 1); add(new JigsawPiece("meteor_dragon_crate_crab", StructureManager.meteor_dragon_crate_crab) {{ blockTable = crates; }}, 1); + fallback = "headback"; }}); put("fallback", new JigsawPool() {{ add(new JigsawPiece("meteor_fallback", StructureManager.meteor_fallback) {{ blockTable = bricks; }}, 1); @@ -123,6 +124,9 @@ public class NTMWorldGenerator implements IWorldGenerator { put("roomback", new JigsawPool() {{ add(new JigsawPiece("meteor_room_fallback", StructureManager.meteor_room_fallback) {{ blockTable = bricks; }}, 1); }}); + put("headback", new JigsawPool() {{ + add(new JigsawPiece("meteor_loot_fallback", StructureManager.meteor_dragon_fallback) {{ blockTable = crates; }}, 1); + }}); }}; }}); } diff --git a/src/main/resources/assets/hbm/structures/meteor/room10/headloot/loot-fallback.nbt b/src/main/resources/assets/hbm/structures/meteor/room10/headloot/loot-fallback.nbt new file mode 100644 index 000000000..2ce40e053 Binary files /dev/null and b/src/main/resources/assets/hbm/structures/meteor/room10/headloot/loot-fallback.nbt differ diff --git a/src/main/resources/assets/hbm/structures/meteor/room10/room-stairs.nbt b/src/main/resources/assets/hbm/structures/meteor/room10/room-stairs.nbt index 635f3d95e..7cef44a64 100644 Binary files a/src/main/resources/assets/hbm/structures/meteor/room10/room-stairs.nbt and b/src/main/resources/assets/hbm/structures/meteor/room10/room-stairs.nbt differ