improved meteor dungeon stair piece, added loot fallback, and prevent structures generating too far horizontally from the start point

This commit is contained in:
George Paton 2025-02-10 11:36:31 +11:00
parent 977bd3e2b5
commit 7f0c483cb1
5 changed files with 33 additions and 16 deletions

View File

@ -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"));

View File

@ -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<JigsawConnection> unshuffledList : fromComponent.piece.structure.fromConnections) {
List<JigsawConnection> 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 {
}
}
}

View File

@ -50,23 +50,23 @@ public class NTMWorldGenerator implements IWorldGenerator {
}});
Map<Block, BlockSelector> bricks = new HashMap<Block, BlockSelector>() {{
put(ModBlocks.meteor_brick, new MeteorBricks());
}};
Map<Block, BlockSelector> crates = new HashMap<Block, BlockSelector>() {{
put(ModBlocks.meteor_brick, new MeteorBricks());
put(ModBlocks.crate, new SupplyCrates());
put(ModBlocks.meteor_spawner, new CrabSpawners());
}};
Map<Block, BlockSelector> ooze = new HashMap<Block, BlockSelector>() {{
put(ModBlocks.meteor_brick, new MeteorBricks());
put(ModBlocks.concrete_colored, new GreenOoze());
}};
put(ModBlocks.meteor_brick, new MeteorBricks());
}};
Map<Block, BlockSelector> crates = new HashMap<Block, BlockSelector>() {{
put(ModBlocks.meteor_brick, new MeteorBricks());
put(ModBlocks.crate, new SupplyCrates());
put(ModBlocks.meteor_spawner, new CrabSpawners());
}};
Map<Block, BlockSelector> ooze = new HashMap<Block, BlockSelector>() {{
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<String, NBTStructure.JigsawPool>() {{
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);
}});
}};
}});
}