This issue has been popping up in a few of the larger 1.12 modpacks. It seems to be caused by too many recipes being unlocked at one time.
java.lang.ArithmeticException: / by zero
at net.minecraft.client.gui.toasts.RecipeToast.func_193653_a(SourceFile:41)
at net.minecraft.client.gui.toasts.GuiToast$ToastInstance.func_193684_a(SourceFile:115)
at net.minecraft.client.gui.toasts.GuiToast.func_191783_a(SourceFile:35)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1119)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:397)
at net.minecraft.client.main.Main.main(SourceFile:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Here is the code for the method. At first I thought it was because recipesOutputs was empty, however there is a check for that.
public IToast.Visibility draw(GuiToast toastGui, long delta)
{
if (this.hasNewOutputs)
{
this.firstDrawTime = delta;
this.hasNewOutputs = false;
}
if (this.recipesOutputs.isEmpty())
{
return IToast.Visibility.HIDE;
}
else
{
toastGui.getMinecraft().getTextureManager().bindTexture(TEXTURE_TOASTS);
GlStateManager.color(1.0F, 1.0F, 1.0F);
toastGui.drawTexturedModalRect(0, 0, 0, 32, 160, 32);
toastGui.getMinecraft().fontRenderer.drawString(I18n.format("recipe.toast.title"), 30, 7, -11534256);
toastGui.getMinecraft().fontRenderer.drawString(I18n.format("recipe.toast.description"), 30, 18, -16777216);
RenderHelper.enableGUIStandardItemLighting();
toastGui.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase)null, this.recipesOutputs.get((int)(delta / (5000L / (long)this.recipesOutputs.size()) % (long)this.recipesOutputs.size())), 8, 8);
return delta - this.firstDrawTime >= 5000L ? IToast.Visibility.HIDE : IToast.Visibility.SHOW;
}
}
5000L / (long)this.recipesOutputs.size() will be 0 if this.recipesOutputs.size() > 5000, that looks like it could cause this?
I was about to shake my fist at mojang, but honestly how are you unlocking more than 5000 recipes at the same time? That's kind of scary.
One example is the command /recipe give @p * which grants a player all recipes (useful for debugging or people who don't care about recipes gradually being unlocked). Otherwise its an extreme edge case that probably will not happen in survival unless you have a ridiculous amount of recipes linked to a single condition.
Or http://quark.vazkii.us/#tweaks-automatic-recipe-unlock?
The recipe give command shows toasts? shakes fist at mojang
Alright this definitely needs a fix then.
Yeah, while it is probably terribly inefficient, it is kinda fun to watch every item rapidly flash in the toast area.
Though, one alternative fix would be to just block /recipe from showing toasts. It would be a minor loss.
As a possible fix, changing the code to will keep the result from becoming 0.(5000 + size) / size
I am dumb, just adding 1 is easier.
If you can add new recipes in vanilla, this is a vanilla bug. Can you write up a bug report and link it here?
I don't think you can add recipes in vanilla at present. I believe it is intended for 1.13, so it might still be worth reporting?
Ah right that didn't actually make it into 1.12.
I guess we should just fix it. They are most likely working on that stuff now and will run into the issue themselves long before they see our bug report.
This issue was weird for me... As it wasn't present when i was updating my modpack and it loaded perfectly (then again i was using an existing world) and I went to play the pack to find any bugs... created a new world and issue started.
Or math max that zero with 1
Fixed by rearranging the operations in a way that it will never divide by 0.
delta / (5000 / size) == delta * size / 5000
Most helpful comment
Ah right that didn't actually make it into 1.12.
I guess we should just fix it. They are most likely working on that stuff now and will run into the issue themselves long before they see our bug report.