What technically defines what a "Nether Fortress" is in terms of mob spawning?
Wither Skeletons and Blazes can spawn naturally in Nether Fortresses but what technically defines what is a Nether Fortress? I could not find any information about it. It's not a technical biome it's just "Hell". Stated in this question's answer and the wiki it's not from the blocks either.
I'm not asking for what defines a Nether Fortress optically for the player but what defines it for the mob spawning process.
Solution 1:
According to the decompiled sources, Minecraft stores the location and volume of generated structures such as villages and Nether fortresses in a separate data structure to the actual blocks that we see in the game. Part of this data structure is a list of mobs that can spawn in that volume of blocks.
Each Structure is composed of Structure Pieces, and each Structure Piece has its own bounding box and mob list. A single Piece can spawn multiple other Pieces adjacently if the type of structure allows it, so one Nether bridge can trigger the placement of another bridge span, or a Blaze spawn platform, or a room, or a tower, etcetera. This is what creates the sprawl of "one" Nether fortress – what we think of as a Nether fortress is really a bunch of independent Structure Pieces that happen to be side-by-side. You can see that in the second video of BlaXpirit's answer, where each red-lined box is a different Structure Piece placed by the structure generator. Each of those bounding boxes are sized to fully encompass all blocks placed by that one Piece's block generator.
For the purpose of spawning Wither Skeletons, all locations in a Nether fortress can spawn them, assuming that spot is a valid spawn location for a mob pack in the first place. It's not "some locations" at all, but every single block, including air, that is within any Nether Fortress Structure Piece bounding box. The code works like this:
- The spawning algorithm selects a single X,Y,Z coordinate to check.
- If it's a valid spawn location according to light levels and solidity, it will spawn a mob there.
- To figure out what mob to spawn, it queries the world data structure to find out if that coordinate is inside a Structure.
- The world data structure finds all Structures that claim blocks in that chunk and then ask them if the coordinate is within one of their bounding boxes. (Structure bounding boxes don't overlap.)
- We'll say the spot is confirmed to be inside a Nether fortress Structure Piece bounding box. The bounding box is a rectangular volume that encompasses the Piece. Nether fortress pieces are usually made of straight sections of blocks, making it unlikely for the bounding box to contain much outside the walls, but it's possible. This means that the spawn coordinate can actually be outside the walls of the fortress in unusual block layouts, especially if the fortress has been changed.
- The spawning algorithm then asks the Structure Piece for its mob list. Nether fortress Pieces' list is Blazes, Magma Cubes, Skeletons, and Zombie Pigmen. We'll say it picks Skeleton.
- The spawning algorithm places a mob pack on that coordinate. Because packs spawn multiple individual mobs in a radius from the pack coordinate, this can actually place the mob outside of the walls of a fortress, if there is valid ground there.
- Placing a Skeleton in the Nether triggers a check: 80% of the time it will be a Wither Skeleton, otherwise a normal Skeleton.
Consequently, Wither Skeletons can spawn everywhere inside of a Nether fortress that is a legal spawn location for mobs, and can sometimes spawn on blocks slightly outside of the volume claimed by the Nether fortress' Pieces. The region is fixed and unchangeable after the fortress is generated. One implication is that you could maximise Wither Skeleton spawning by adding more layers of blocks within the Piece's volume, to convert more air spaces into legal spawning pads.
Solution 2:
Mobs don't just spawn anywhere in a Nether Fortress, but in particular sections of it. And even if you replace all the blocks of a Fortress, the same regions will still spawn Wither Skeletons.
This video explains this:
And this one shows it graphically:
Solution 3:
In your save folder there is a folder called "data." Inside that is a file called "Fortress.dat." This is where minecraft checks for the "Structure Bounding Box" that SevenSidedDie referenced in his answer, which I think is correct. Therefore it's possible to see exactly where Minecraft considers a valid Nether Fortress spawning space, and even change it!
If you open Fortress.dat with an NBT editor (I used NBTExplorer, now often considered the best) you are given a list of all the Nether Fortresses in your world thus far, organized by the chunk they began generating in. As you explore more of your world, this list gets bigger as more are generated. Generation starts with the "seed" of the fortress, which is a single room, and then it expands from there, adding conjoining rooms by following some algorithm.
Inside of each fortress are different tags. There is a "chunkX" and "chunkY" tag, which gives the chunk that the beginning of each fortress is in. the "id" tag identifies this structure as a nether fortress. The "BB" tag gives the coordinates of the entire range of the fortress, in the format "X1 Y1 Z1 X2 Y2 Z2." The entirety of the fortress fits inside this bounding box. However, special mobs don't spawn anywhere inside this box, for that you have to go to a higher resolution.
Each fortress is made up of many different segments, as others have talked about, such as a "stairs" or a "corridor crossing." Also in the fortresses folder, along with the other tags I described above, is a List called "Children." Inside of this are 50-200 entries, each representing one of these segments, each with 4 or 5 entries each. They are 'GD,' 'O,' 'id,' 'BB,' and optionally 'seed.'
Now, I don't know what 3 of these entries mean, but I do know what I think are the most important. 'id' describes what type of segment it is, such as "NeSC" for maybe "Nether Stair Case" or "NeBCr" for "Nether Bridge Crossing" (This type of segments is the one you want for farms, as they are the largest, being 19X19) There is always one "NeStart," this is the seed from which the rest of the fortress grows on generation.
BB also describes the bounding box in the same nomenclature as above. Worth noting is that if the BB is "0 0 0 4 4 4" the spawnable area is actually a 5X5X5 box, as the range is inclusive, as far as I can tell. Also, I've heard, but can't confirm, that these are coordinates relative to the region(a 32X32 block of chunks). I was near the origin, so the coordinates corresponded exactly to the generated fortress in my world and where wither skeles would spawn, but if you go farther away, these BB coordinates would remain in a 256 integer range when the real world coords could be much higher.
Warning: If you attempt to add another bridge segment to this list, your game will crash, as far as I can tell. What I needed to do was fix part of my fortress that stopped spawning wither skeles for some reason after I upgraded versions, so what I did instead was simply edit the coordinates of another segment to where I needed. After I reloaded the world (necesarry!) wither skeles spawned again whereever I made one of these segment BB tags encompass.
Might not have been the clearest, but hope that helped!