mojira.dev
MC-115940

Division by zero crash with alternating /recipe commands

To reproduce

Run a

/recipe give @p *

command in quick oscillating succession with

/recipe take @p *

It will crash the game with a Divide By Zero error like the one in the

[media]

log. My sparse tests show it won't crash if there are 8 redstone ticks between the commands, but it will crash if there are only 2 redstone ticks between them. More testing can narrow down the range, I'm sure, but I don't think the exact timing is important here.

[^crash-2017-04-12_22.17.28-client.txt]

Description: Unexpected error

java.lang.ArithmeticException: / by zero
	at bio$b.a(SourceFile:187)
	at bio.a(SourceFile:44)
	at bgu.aw(SourceFile:985)
	at bgu.a(SourceFile:399)
	at net.minecraft.client.main.Main.main(SourceFile:123)

Why?

Before anyone says "well, don't do that!", there's a legitimate reason to quickly give and take recipes like that. I was using a location-based advancement to test the biome the players are in, and only allow them to craft in certain areas of the map. To do this, I have to take all recipes every tick, check if they have the advancement, and if so, give them back their recipes and revoke the advancement. Alternately, I could only take their recipes if they haven't earned the advancement, but even then, if they cross from one biome into the next quickly enough, it will trigger the crash. And we don't want our custom maps completely crashing Minecraft for players, do we?

Linked issues

Attachments

Comments 4

It's pretty funny that a division by zero crashes the game xD

It crashes any program as it is an impossible operation.

Shouldn't it just return 0?

No, learn math, it's an impossible to solve problem.

Daniel Burnett

Nathan Adams

Confirmed

crash, recipe

Minecraft 17w15a

Minecraft 17w17a

Retrieved