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

Spawner with weight 0 crashes game

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 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
    • Fix Version/s: Minecraft 1.12.2
    • Confirmation Status:
      Confirmed

      Description

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

      summon spawner_minecart ~ ~1 ~ {Delay:-1,SpawnPotentials:[{Weight:0,Entity:{id:pig}}]}
      

      The world starts back up just fine. You can even log in and see the spawner_minecart. Indeed a weight of 0 makes no sense, but this shouldn't cause the entire game to crash.

      Crash log attached.

      15w45a
      Description: Ticking entity
      
      java.lang.IllegalArgumentException
      	at ov.a(SourceFile:18)
      	at ov.a(SourceFile:37)
      	at ahe.i(SourceFile:129)
      	at ahe.c(SourceFile:69)
      	at yh.m(SourceFile:66)
      	at ahn.a(SourceFile:1481)
      	at lq.a(SourceFile:719)
      	at ahn.g(SourceFile:1459)
      	at ahn.k(SourceFile:1349)
      	at lq.k(SourceFile:552)
      	at net.minecraft.server.MinecraftServer.D(SourceFile:618)
      	at net.minecraft.server.MinecraftServer.C(SourceFile:546)
      	at bxx.C(SourceFile:154)
      	at net.minecraft.server.MinecraftServer.run(SourceFile:450)
      	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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Arcensoth Arcensoth
              • Votes:
                8 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: