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

Spawner with weight 0 crashes game

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.12.2, 21w03a
    • Minecraft 1.8.8, Minecraft 15w39c, Minecraft 15w40b, Minecraft 15w45a, Minecraft 15w47c, Minecraft 15w51b, Minecraft 1.9.4, Minecraft 16w35a, Minecraft 1.11, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12 Pre-Release 5, Minecraft 1.12 Pre-Release 7, Minecraft 1.12, Minecraft 18w05a, Minecraft 1.14.3 Pre-Release 2, 1.14.4, 19w38b, 1.15.2, 20w15a, 1.16.2, 1.16.3, 1.16.4, 20w46a
    • Confirmed
    • Crash
    • Very Important

      A spawner with SpawnPotentials containing an entry with a Weight of 0 causes the game (or server) to crash:

      /setblock ~ ~ ~ spawner{Delay:-1,SpawnPotentials:[{Weight:0,Entity:{id:pig}}]}
      

      Crash log attached.

      1.14.3 pre-2
      Description: Ticking block entity
      
      java.lang.IllegalArgumentException
      	at aaf.a(SourceFile:18)
      	at aaf.a(SourceFile:37)
      	at bgs.i(SourceFile:179)
      	at bgs.c(SourceFile:91)
      	at bup.T_(SourceFile:62)
      	at bhl.K(SourceFile:625)
      	at vi.a(SourceFile:402)
      	at net.minecraft.server.MinecraftServer.b(SourceFile:824)
      	at net.minecraft.server.MinecraftServer.a(SourceFile:763)
      	at dxn.a(SourceFile:128)
      	at net.minecraft.server.MinecraftServer.run(SourceFile:631)
      	at java.lang.Thread.run(Thread.java:745)
      

      The reason for this is that the game throws a IllegalArgumentException in case the sum of all weights is <= 0. This means this bug is also caused when negative weights are provided or when the weights overflow:

      setblock ~ ~1 ~ mob_spawner 0 replace {Delay:-1s,MinSpawnDelay:3s,MaxSpawnDelay:3s,SpawnPotentials:[{Entity:{id:armor_stand},Weight:2147483647},{Entity:{id:armor_stand},Weight:1}]}
      

      This affects also loot tables but only if the weight sum overflows. There it does not crash but prints the exception in the log only.

            Unassigned Unassigned
            Arcensoth Arcensoth
            Votes:
            9 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: