mojira.dev
MC-89880

Spawner with weight 0 crashes game

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.

Linked issues

Attachments

Comments 6

Confirmed for

  • 15w51b

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:"ArmorStand"},Weight:2147483647},{Entity:{id:"ArmorStand"},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.

Confirmed for 1.9.4. See attached crash report

[media]

Confirmed for 1.11.2 but no crash report (only said in the launcher that it crashed)

The command now fails with an error instead of crashing. Changing the 0 to any other number causes the summon to work, therefore it seems this is meaningfully fixed.

The block version still crashes the game. Reopened, updated crash report and command.

This still crashes the game as of 1.16.4.

Arcensoth

(Unassigned)

Confirmed

Very Important

Crash

crash, mob_spawner, spawner_minecart

Minecraft 1.8.8, Minecraft 15w39c, Minecraft 15w40b, Minecraft 15w45a, Minecraft 15w47c, ..., 20w15a, 1.16.2, 1.16.3, 1.16.4, 20w46a

Minecraft 1.12.2, 21w03a

Retrieved