Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-253542

Spawner blocks with SpawnPotential and no SpawnData will crash during worldgen


    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w43a
    • 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

      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.

        1. crash-2022-07-30_12.20.35-server.txt
          8 kB
        2. deobf_crash-2022-07-30_12.20.35-server.txt
          35 kB
        3. latest.log
          23 kB
        4. MC-253542.png
          161 kB
        5. spawner_nbt_crash.zip
          11 kB

            panda4994 [Mojang] Panda
            TelepathicGrunt TelepathicGrunt
            5 Vote for this issue
            5 Start watching this issue