Mojira Archive
MC-87655

Arrows with negative damage can crash the game on hitting an enemy

Arrows with negative damage can crash the game on hitting an enemy.

This crash is strange, because crash seems to be dependent both on just how negative the damage is, and on the distance from player to the hit mob.

How to Reproduce:

1. Place an Always Active Repeat Command Block anywhere in the world with the following command inside:

execute as @e[type=arrow] run data merge entity @s {damage:Xf}

The exact value of X determines if the game will crash.

2. Place and immobilize two Villagers, one 5 blocks away from the player, second around 25 blocks away.

3. Shoot a villager with the bow. Be sure that the arrow will be in the air for at least one tick for the command to work.

4. Depending on the value of X and which Villager you shoot, the following things should happen:

X = -1.0:
Near Villager: Game Doesn't Crash
Far Villager: Game Doesn't Crash

X = -1.4:
Near Villager: Game Crashes
Far Villager: Game Doesn't Crash

X = -1.5:
Near Villager: Game Crashes
Far Villager: Game Crashes

For all X lower than -1.5, game always crashes on hitting any of the villagers.

Description: Ticking entity

java.lang.IllegalArgumentException: bound must be positive
	at java.util.Random.nextInt(Random.java:388)
	at aoj.b(SourceFile:368)
	at aoj.a(SourceFile:335)
	at aoj.R_(SourceFile:264)
	at aol.R_(SourceFile:99)
	at axx.a(SourceFile:1243)
	at td.a(SourceFile:575)
	at axx.g(SourceFile:1218)
	at axx.o_(SourceFile:1100)
	at td.o_(SourceFile:491)
	at net.minecraft.server.MinecraftServer.b(SourceFile:755)
	at net.minecraft.server.MinecraftServer.a(SourceFile:681)
	at dgg.a(SourceFile:131)
	at net.minecraft.server.MinecraftServer.run(SourceFile:584)
	at java.lang.Thread.run(Thread.java:745)