Modscraper Modscraper Minecraft
Structure Layout Optimizer logo

Structure Layout Optimizer

Mod

by telepathicgrunt

Attempts to optimize the generation of Jigsaw Structures and NBT pieces

Type

Mod

CurseForge Downloads

31,441,139

CurseForge ID

1087831

Modrinth Downloads

8,459,223

Modrinth ID

ayPU0OHc

Last Updated

Nov 7, 2026

Description

Optimizes general Jigsaw structure generation as best I can. Essentially this mod aims to not change how structures look at all. It only works to try and make structures generate faster and more efficiently. That's it.

 

Here are the more technical details of the optimizations done. Please report any conflicts or issues that is discovered when running this mod in your modpacks!

 

  • Replaces VertexShape unoptimized calls with a BoxOctree to make pieces only check nearby pieces for intersections instead of entire structure.


By default, vanilla uses a VoxelShape to store the bounds of pieces it is assembling for the structure layout. When it goes to add a new piece, it needs to see if it will fit into the layout without intersection any other pieces.

The issue is VoxelShape is not good for this purpose as when checking if a VoxelShape intersects another VoxelShape, ALL the vertices are compared. In Jigsaw structures with lots and lots of pieces, this intersection check slows down greatly the more valid pieces are added to the layout. Can cause a lag spike when generating high number of pieces for recursive Jigsaw structures.

The optimization here replaces the normal VoxelShape with a dummy VoxelShape that holds a BoxOctree implementation inside in order to pass around the BoxOctree to where it needs to be. This BoxOctree, when checking for intersections, will check only the nearby pieces to the incoming bounding box. Thus preventing the runaway growth in intersection checking time as it'll ignore the majority of pieces as they are too far away to matter for the check.

 

  • Check if a Jigsaw Block is blocked off entirely to know when to skip checking child rigid pieces.


In vanilla, every single Jigsaw Block in the parent piece will check every single Jigsaw Block in a child piece to know when to attempt to connect the two pieces. The issue is if the parent piece's Jigsaw Block is facing the edge of the structure boundary OR is facing another separate piece, then that Jigsaw Block has no room to ever spawn a rigid structure piece. Therefore, we can tell the game to skip checking this rigid child piece and check the next piece instead. This saves us from doing lots of expensive Jigsaw Block match up checks. Especially in structures that have a huge number of Jigsaw Blocks.

 

  • (26.2 and below) Replaces Jigsaw target/facing match up with a slightly more optimized version.


Reduces the number of block properties grabbing by half. Vanilla calls getValue twice for each JigsawBlock to get top and front values from the same property when it could just grab it once and get all values it needs. Slightly improved the speed of getting the joints, targets, and name string values from the Jigsaw Blocks's NBT as well. Also simplify joint data checking to not need to be converted to an Enum with byName (not performant) and reordering checks to reduce amount of logic that needs to run often.

This will help with Jigsaw structures that have a very high amount of Jigsaw Blocks in them as each Jigsaw Block runs through this matching code for all Jigsaw Blocks in the other structure pieces.

 

  • Made any giant structure NBT that has no finalizeProcessing StructureProcessor now load much faster.


When a NBT structure piece goes to generate in a chunk, the ENTIRE NBT piece is loaded into memory, and then iterated over all the positions multiple times for StructureProcessors to apply and then later ignores all the positions outside the currently generating chunk. This is not very efficient (really wasteful) and causes large load times for giant NBT files.

This mod's optimization works by doing the bounds check early to strip out all positions that we don't need before passing it to the StructureProcessors. However, any StructureProcessor that overrides finalizeProcessing method could require all the NBT positions to function correctly so this optimization is disabled for any pieces with these kinds of StructureProcessors which will be very few structures. In vanilla, only Trail Ruins will not get this optimization due to its use of the Capped StructureProcessor that overrides finalizeProcessing method.

 

  • (1.21.1+) Replaced the Jigsaw Block list shuffling and prioritization logic in SinglePoolElement with a slightly faster version.


Main benefit is slightly faster `selection_priority` data grabbing from NBT by using a new method that grabs the entry once instead of twice. Vanilla does it twice to check the data type first before returning the value. A bit odd and wasteful.

Also tried a new sorting system for the prioritization, but only helps the few structures that actually makes use of `selection_priority` like Trials Chamber. Overall, this is probably the weakest optimization but it does quite a bit of help for Jigsaw structures that has an absolutely ridiculous amount of Jigsaw Blocks. So it is worth keeping this optimization.

Might break parity with vanilla seeds in regard to what order the Jigsaw Block are ran in, but I could not find evidence of this yet.

 

  • Skip running logic for SinglePoolElements we already checked and could not spawn at the current spot.

 

So this optimization comes from the fact that vanilla StructureTemplatePool holds a list of all the SinglePoolElements with duplicates of the elements based on their weight value. So if in a Template Pool, you specify weight 100 for a house, that house will be put into this list 100 times! And when generating the layout, the game will make a copy of this list, shuffle it, and iterate over the list to try and spawn the first piece it finds that fits. This means it will rerun the checking logic for duplicate entries in this list even if it was found to not fit before at the spot. The optimization I do is skip the logic for pieces we already checked before and continue to the next piece in the list. This gives a nice performance boost for structures that uses a lot of high weight values in their Template Pools.

 

Furthermore, you can turn on the `deduplicateShuffledTemplatePoolElementList` config option to get even more performance out of high weight elements in Template Pools. The issue is this config comes at a cost of changing the layout of the structure. The layout is still valid and good. It would just be different than if the config option is kept off. Basically it breaks seed parity for structure layouts specifically to get that extra performance boost.

 

*To be clear, seed parity is every time you use the seed 777 and there is a village at a spot with 2 blacksmith houses, every time you use that same seed, that village will remain at that spot with the two blacksmith houses. With this optimization config turned on and same seed, that village will still be at same spot. But it may have 1 blacksmith house this time. And every time you use the same seed with this config on, the village will continue to generate with the 1 blacksmith house. The layout is seed stable. But just no longer is the same as if the config is turned off.

 

 

  • (1.21.4 with v1.1.0+): Swap StructureTemplate$Palette's list of StructureBlockInfo objects to be a palette of StructureBlockInfo objects instead for reduced memory usage when not generating that cached StructureTemplate.

 

This optimization is a modified form from contaria's Glacier mod for 1.16.1. Special thanks to them for allowing me to use their code as a basis for this optimization!

 

Essentially in vanilla, every time a structure nbt file is loaded, it is converted to a StructureTemplate object and cached. Buried in that object is a list of ALL the positions from that nbt file paired with the blocks and nbt tag at each position. This is the biggest memory hog for StructureTemplate objects. What this mod will do is swap this list with a special palette data structure object under the hood that pretends to be a list. The memory size of the palette is significantly smaller than the list! Then when queried for worldgen, it will construct the list again as a WeakReference so worldgen remains fast and works properly. And when worldgen is done, this list will get garbage collected to free up memory again, allowing each StructureTemplate to only use the full amount of memory they need when doing worldgen but stay cached in a smaller form long term. The downside is this list cannot and should not be modified with add, remove, clear calls and will throw and exception if done. Luckily, I do not think any mod is modifying this list itself on StructureTemplate directly but if they do, please let me know.

 

ModernFix does have a mixin that will make the StructureTemplate objects themselves be a SoftReference and be removed completely from memory when the game gets full on memory. This is a valid solution and aims to stop the memory leak of loading structure nbts into a cache that never clears in long term gameplay. The downside of this is that the piece has to be loaded directly from the file again if it was cleared from memory. This mixin will work just fine alongside my mod's optimization. What will probably happen is my mod make StructureTemplate smaller in memory which allows ModernFix to keep more StructureTemplates in memory without them getting fully removed from memory. Which should allow more cache hits over long term. In theory.

 

 

 

 

Compatibility

Mod Loaders

Fabric Server

Game Versions

26.3

Recommended Gear

Affiliate

Hardware and extras that pair well with this mod.

As an Amazon Associate I earn from qualifying purchases.

Similar Mods

Included in Modpacks (682)

Show fewer
Mystic's Monstrosity Mystic's Monstrosity World Terra World Terra Actions on Java Actions on Java DayOfMind DayOfMind HP - Create World of Gears - Create 6.0.9 HP - Create World of Gears - Create 6.0.9 MC Vanilla 2.0 - QUALITY UPDATE! MC Vanilla 2.0 - QUALITY UPDATE! Easycraft (Official) Easycraft (Official) Danny's AOT - Titan Chronicles Danny's AOT - Titan Chronicles Kuri's Fresh (Actions & Stuffs recreation) Kuri's Fresh (Actions & Stuffs recreation) StaTech Industry 2 StaTech Industry 2 Desecrated - Flesh and Blood Desecrated - Flesh and Blood Lees Zombie Apocalypse - Fallen Earth Lees Zombie Apocalypse - Fallen Earth Pojavly Optimized Pojavly Optimized My Biome Is So Beautiful My Biome Is So Beautiful antarchy craft antarchy craft [MODIFIED] Cobblemon: OVERCLOCKED! [MODIFIED] Cobblemon: OVERCLOCKED! Arcane Dragons [FABRIC] Arcane Dragons [FABRIC] Terramity Awakened Terramity Awakened Create Lets Create - Official Server Create Lets Create - Official Server Druidic Quest: Expert Druidic Quest: Expert Legacies 26 Legacies 26 Legacies Legacies Enigmatic Skies Enigmatic Skies Angel Tale : Shadows of Apollyon Angel Tale : Shadows of Apollyon Cozy Time | Cozy Survival with Quests (MC Cozy 1.21.1) Cozy Time | Cozy Survival with Quests (MC Cozy 1.21.1) WinterCraft-Eternal Winter! WinterCraft-Eternal Winter! Arcane Colony: The Tinker’s Age Arcane Colony: The Tinker’s Age Immersive Cobblemon | With Distant Horizons, CobbleBrain, Cobblemon Addons & Quests (Cobblemon v1.7.3) Immersive Cobblemon | With Distant Horizons, CobbleBrain, Cobblemon Addons & Quests (Cobblemon v1.7.3) Shaders - Working Shaders - Working More FPS More FPS Monumental Experience - In the Sky Monumental Experience - In the Sky Ultra Hardcore Renewed - Do you dare to play it? | 1.21 UPDATE! Ultra Hardcore Renewed - Do you dare to play it? | 1.21 UPDATE! EL MINE MAS EPICO 2 EL MINE MAS EPICO 2 Immersive Experience - Inspired by Actions & Stuff and Other Immersive Mods Immersive Experience - Inspired by Actions & Stuff and Other Immersive Mods Furniture & Tech Furniture & Tech Hammer Hammer Crazy Crave 5 Crazy Crave 5 Create Sky Colonies - Valkyrian Skies X Create 6.0 Create Sky Colonies - Valkyrian Skies X Create 6.0 Create - Above the Horizon Create - Above the Horizon Ender's Journey - Beyond The End Ender's Journey - Beyond The End Hexxit Revived Hexxit Revived Cave horror optimized (cave horror project 1) Cave horror optimized (cave horror project 1) LunarFox LunarFox Void's essentially optimized pack Void's essentially optimized pack Lees Fantasy - Chronicles of the Mimic Lees Fantasy - Chronicles of the Mimic Plants vs. Zombies+ | With Plants vs Zombies & More! Plants vs. Zombies+ | With Plants vs Zombies & More! OneClient (SkyBlock) OneClient (SkyBlock) Cosmic Frontiers Cosmic Frontiers Shiner's Black Clover Shiner's Black Clover Forget Me Not Forget Me Not White Shrimp's Great Adventure White Shrimp's Great Adventure The Zombie Conquest The Zombie Conquest [Ck7] Pack de Optimización [Ck7] Pack de Optimización Mystic's Monstrosity - Greedy Edition Mystic's Monstrosity - Greedy Edition Path of the Ascended Path of the Ascended Big Globe Optimized (FORGE) Big Globe Optimized (FORGE) Tensura All The Slime 1 Tensura All The Slime 1 Better Experience (BTV) - Last Update! | The Copper Age! Better Experience (BTV) - Last Update! | The Copper Age! crazy craft even more updated crazy craft even more updated Better than Better Than Wolves ( BTBTW ) Better than Better Than Wolves ( BTBTW ) Voxy with Shaders Voxy with Shaders Monumental Experience - Creatures Across the World Monumental Experience - Creatures Across the World Realisticraft - The Realistic Experience Realisticraft - The Realistic Experience Lunchbutt's Modpack Lunchbutt's Modpack TNF-Vanilla TNF-Vanilla Just Hide - A Ransomware Horror Experience (Inspired by Twixxel & Thatmob) Scary Stalker Gameplay Recreation Modpack Just Hide - A Ransomware Horror Experience (Inspired by Twixxel & Thatmob) Scary Stalker Gameplay Recreation Modpack Mechanomania Mechanomania Infinity Legacy Infinity Legacy Smooth Server Smooth Server Liminal Industries - Rescripted Liminal Industries - Rescripted Farming Overloaded Farming Overloaded IanAnderson's Modpack IanAnderson's Modpack PVP Pack [PvP ,  FPS Boost ,  Performance ,  Optimization ,  Low Latency ,  Competitive ,  26.2 , Modern PVP , pvppack , pvp] PVP Pack [PvP , FPS Boost , Performance , Optimization , Low Latency , Competitive , 26.2 , Modern PVP , pvppack , pvp] Enchanted Genesis Enchanted Genesis Ben  10 MINEDITION Ben 10 MINEDITION VampireReborn VampireReborn Create Overlord Aeronautics Update Create Overlord Aeronautics Update Spell Sword Spell Sword The Corrupted Aftermath The Corrupted Aftermath Just Enough Optimization Just Enough Optimization Fastest Client Fastest Client Apocalypse Begins [Zombie Apocalypse] Apocalypse Begins [Zombie Apocalypse] The Forest - The Ultimate Survival Horror Pack The Forest - The Ultimate Survival Horror Pack Mojo Optimized Mojo Optimized Keo Create Optimized Keo Create Optimized Neuroshroud: The Abandoned Neuroshroud: The Abandoned The Clash of Epochs The Clash of Epochs Steller: The Rise of the Kingdom Steller: The Rise of the Kingdom Ultimate Tensura Reincarnated Ultimate Tensura Reincarnated Reverie Foundry Reverie Foundry Keo Create Optimized Keo Create Optimized Moonstruck's Rebirth - A Better Cozy Experience Moonstruck's Rebirth - A Better Cozy Experience [MODIFIED] Cobblemon: Essentials [MODIFIED] Cobblemon: Essentials SharpSharp RPG SharpSharp RPG World Destroying - Apocalipse Zombie World Destroying - Apocalipse Zombie Fresh & Cozy Fresh & Cozy Create: Basically Everything Create: Basically Everything EMC & FE +++ EMC & FE +++ Simple Performance Simple Performance Nature's Journey Nature's Journey

External Resources