-
Bug
-
Resolution: Fixed
-
1.19, 1.19.1
-
None
-
Confirmed
-
Crash
-
Important
If a spawner block is saved into an nbt file for structures and then is edited to delete its SpawnData field but keep its SpawnPotential field, loading that nbt file by worldgen structure or worldgen feature will crash the game.
The expected behavior is that the SpawnPotential would pick on entry from itself and create the SpawnData info automatically. This expected already happens when doing this command in a world:
/setblock ~ ~ ~ spawner {"SpawnPotentials":[{"data":{"custom_spawn_rules":{"block_light_limit":{"max_inclusive":15,"min_inclusive":0}},"entity":{"id":"minecraft:drowned"}},"weight":1}]}
The issue is caused by the BlockEntity's load method being called right away during worldgen block placing where it's level field is currently null. In order for the SpawnPotentials to pick which entry to use for SpawnData, it needs a random. Before 22w15a, the spawner block entity used this.random to do the picking. Now it is trying to do this.level.getRandom() which will crash because level is null.
Attached is a datapack to reproduce the issue. Locate and teleport to any plains village and the crash will happen because the datapack replaces the town center of the village to have a spawner block with SpawnPotential but no SpawnData.