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

Division by zero crash with alternating /recipe commands

XMLWordPrintable

    • Confirmed

      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 attached crash 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.

      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?

            dinnerbone [Mojang] Nathan Adams
            IceMetalPunk Daniel Burnett
            Votes:
            5 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: