Mojira Archive
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.