Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-120572

/recipe crashes the game

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 18w07c, Minecraft 1.13-pre5, Minecraft 1.13, Minecraft 18w31a, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w03b, Minecraft 19w03c, Minecraft 1.14 Pre-Release 2, Minecraft 1.14 Pre-Release 3, Minecraft 1.14 Pre-Release 4, Minecraft 1.14 Pre-Release 5
    • Fix Version/s: None
    • Confirmation Status:
      Confirmed
    • Category:
      Commands, Crash

      Description

      The bug & how to reproduce it

      If a redstone clock powers command blocks with

      1. /recipe give @a *
      2. /recipe take @a *

      in them the game crashes with following error-report:

      18w07c
       
      Description: Unexpected error 
      
      java.lang.ArithmeticException: / by zero 
      at bjz.a(SourceFile:41) 
      at bkc$a.a(SourceFile:115) 
      at bkc.a(SourceFile:35) 
      at bib.az(SourceFile:1025) 
      at bib.a(SourceFile:419) 
      at net.minecraft.client.main.Main.main(SourceFile:123) 
      [...] 
      
      1.13-pre5
      [15:21:49] [Server thread/INFO]: [@: Took 524 recipes from Gewinner413]
      [15:21:49] [Server thread/INFO]: [@: Unlocked 524 recipes for Gewinner413]
      [15:21:49] [Client thread/FATAL]: Unreported exception thrown!
      java.lang.ArithmeticException: / by zero
      	at cgu.a(SourceFile:44) ~[1.13-pre5.jar:?]
      	at cgx$a.a(SourceFile:112) ~[1.13-pre5.jar:?]
      	at cgx.a(SourceFile:32) ~[1.13-pre5.jar:?]
      	at cep.c(SourceFile:810) ~[1.13-pre5.jar:?]
      	at cep.a(SourceFile:373) [1.13-pre5.jar:?]
      	at net.minecraft.client.main.Main.main(SourceFile:143) [1.13-pre5.jar:?]
      

      The .zip file is the world that you can see on the picture with the setup. YouTube video showing the bug.

      Code analysis

      The following is based on a decompiled version of Minecraft 1.12.1 using MCP 9.40pre-1 with new mappings. Code analysis by [Mod] Bemoty

      The code line causing this exception to be thrown is (MCP line 43):

      net.minecraft.client.gui.toasts.RecipeToast.draw()
      toastGui.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase)null, this.recipesOutputs.get((int)(delta / (5000L / (long)this.recipesOutputs.size()) % (long)this.recipesOutputs.size())), 8, 8);
      

      The problem appears to be that the algorithm to determine which item of the item recipes the player receives should be shown in the recipe toast divides delta by zero whenever (long)this.recipesOutputs.size() is > 5000L.

      net.minecraft.client.gui.toasts.RecipeToast.draw()
      this.recipesOutputs.get((int)(delta / (5000L / (long)this.recipesOutputs.size()) % (long)this.recipesOutputs.size()))
      

      Forge team fixed this issue by simply rearranging arithmetic operations in order to make divisions by zero impossible (given that this.recipesOutputs.size() can never be zero):

      FIX: net.minecraft.client.gui.toasts.RecipeToast.draw()
      toastGui.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase)null, this.recipesOutputs.get((int)(delta * (long)this.recipesOutputs.size() / 5000L % (long)this.recipesOutputs.size())), 8, 8);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Linde0404 Linus Nadler
              • Votes:
                10 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: