Repurposed Structures (Fabric/Quilt)

Repurposed Structures (Fabric/Quilt)

20M Downloads

StackOverflowError recursion from repurposedstructures.world.structures freezes the game

Closed this issue ยท 4 comments

commented

I don't know exactly how I'm reproducing this, but in my personal datapack I've added some structure exclusions, and I belive it's the cause of a recursion that freezes all chunk generation in my new world. When I try to quit the game, Minecraft soft locks and I have to force shut it down. I believe this is the offending callstack:

[Worker-Main-22/ERROR] [net.minecraft.Util/]: Caught exception in thread Thread[#222,Worker-Main-22,5,main]
java.lang.StackOverflowError: null
	at TRANSFORMER/[email protected]/net.minecraft.world.level.chunk.ChunkGeneratorStructureState.hasStructureChunkInRange(ChunkGeneratorStructureState.java:198) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement$ExclusionZone.isPlacementForbidden(StructurePlacement.java:48) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.applyInteractionsWithOtherStructures(StructurePlacement.java:101) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:89) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.chunk.ChunkGeneratorStructureState.hasStructureChunkInRange(ChunkGeneratorStructureState.java:198) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement$ExclusionZone.isPlacementForbidden(StructurePlacement.java:48) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.applyInteractionsWithOtherStructures(StructurePlacement.java:101) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:89) 
	at TRANSFORMER/[email protected]+1.21.1-neoforge/com.telepathicgrunt.repurposedstructures.world.structures.placements.AdvancedRandomSpread.isStructureChunk(AdvancedRandomSpread.java:98) ~[repurposed_structures-7.5.15+1.21.1-neoforge.jar%23455!/:?]
	at TRANSFORMER/[email protected]/net.minecraft.world.level.chunk.ChunkGeneratorStructureState.hasStructureChunkInRange(ChunkGeneratorStructureState.java:198) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement$ExclusionZone.isPlacementForbidden(StructurePlacement.java:48) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.applyInteractionsWithOtherStructures(StructurePlacement.java:101) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:89) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.chunk.ChunkGeneratorStructureState.hasStructureChunkInRange(ChunkGeneratorStructureState.java:198) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement$ExclusionZone.isPlacementForbidden(StructurePlacement.java:48) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.applyInteractionsWithOtherStructures(StructurePlacement.java:101) 
	at TRANSFORMER/[email protected]/net.minecraft.world.level.levelgen.structure.placement.StructurePlacement.isStructureChunk(StructurePlacement.java:89) 
	at TRANSFORMER/[email protected]+1.21.1-neoforge/com.telepathicgrunt.repurposedstructures.world.structures.placements.AdvancedRandomSpread.isStructureChunk(AdvancedRandomSpread.java:98) ~[repurposed_structures-7.5.15+1.21.1-neoforge.jar%23455!/:?]

I'm hoping you will be able to see if there's a potential recursion bug in AdvancedRandomSpread.isStructureChunk(). If not, let me know and I'll try to narrow down a repro for this.

NeoForge: 1.21.1
Repurposed Structures: 7.5.15

commented

list all compat datapacks you are using as well as the config datapack if you edited and put it on.

If you are using an outdated version of the compat datapacks for your specific minecraft version, update those.

The issue surrounds the use of exclusion zones in structure sets. If you were adding to those exclusion zones yourself, don't. They are unsafe and need very careful work to not do infinite loops like what you are seeing. If you did not edit the structure sets, then update the compat datapacks as the issue was fixed in a few of them already long ago.

commented

Yes, I created my own modpack that I was using to override structure_set data files to add an exclusion zone. I managed to incidentally fix the issue for myself, but now I'm not able to recreate it. I'm actually wondering if I had a bad JSON file and inadvertently fixed it when trying to set the repro back up. It's possible that this issue was reported because of some circular reference I had, but I tried to recreate it and could not.

As far as custom exclusion zones go, I've now removed all except a few that exclude minecraft:villages, so there will never be any circular references. I have one exception: I added a repurposed_structures:villages_overworld exclusion to each of the Dungeons and Taverns village structure_sets, since they share the same biomes (birch, jungle and swamp).

Generally speaking, I don't like to use exclusion zones, but instead use the Sparse Structures mod, in combination with tweaking spacing values that seem off. You won't believe how many mods do something stupid like Spacing 40, Separation 38. Or maybe you already know this. :)

If you don't see anything that concerns you in your function that is referenced in this callstack, then it sounds like there's no good reason to leave this ticket open. Thanks for the feedback. If I can reproduce this again reliably, and it seems like it should not occur, I can reopen the issue and add new information.

commented

I'll close this as the exclusion zone code is actually vanilla's. Even mojang employees say not to use exclusion zones but I did so but very carefully to avoid circular references.

The ideal solution for a modpack is not to use exclusion zones. But to instead override all relevant structure sets and remove the structures from their structures list. Then make a single master structure set and stick the removed structures into there. Now that structure set's spacing field will enforce a minimum chunks apart for all structures in there. Making it ideal for preventing structure fusions. The weight field can be used to make some structures more likely to spawn if multiple structures are eligible for a biome. Maybe have 1 structure set for all large land structures, 1 for all small common structures, 1 for ocean structures, 1 for underground structures, 1 for sky structures, and 1 for nether structures. End is pretty bare so you may not need to worry about structure fusions there

commented

I agree, and I've put some thought into this already. I've come up with a prefix_suffix system to sort structure sets two dimensionally.

Prefixes: <biome>_, <dimension>_, underground_
Suffixes: _homesteads, _adventure, _pois-large, _pois-small

The main thing stopping me is the amount of work, and needing to add/remove resources every time I enable or disable a mod. As well as the fact that I'm still new to Minecraft, and I don't want to spoil everything (I've already spoiled a lot by having to balance things that are wonky, though). So I'll probably do it one day once I feel I've seen enough of the structures that vanilla and mods have to offer.

And yeah, now that I've seen how the exclusion zones work, I do agree that it's a poor system. It looks simple, but it's really a simple way to shoot yourself in the foot. Useful for very careful, quick hacks if you know what you're doing. Thanks for the comments.