Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4842

Recipe iterator causing errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • macOS 10.14.4

      Java:

      Java(TM) SE Runtime Environment (build 1.8.0_201-b09)

      Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

    •  CraftBukkit version git-Bukkit-8ddb94d
    • Just my test plugin
    • Yes

      Description:

      When iterating thru all recipes, storing them, removing a few recipes from them, clearing all server recipes and then adding the stored ones back, a bunch show up as air. When clicking on the air ones in the recipe book, the client crashes.

      I found a small workaround, which was to not include recipes that resulted in air when adding recipes back to the server. The issue now is that some recipes seem to be missing. Im not sure on ALL of the, but some I noticed were things like firework rockets and and firework stars. 

      My guess as to what is happening here, is when the recipes are iterated, its including recipes that are server recipes but do not show up in the recipe book (ie: firework stars) and when adding them back in the server, they have a result of air, therefor showing up in the recipe book as air, and making this error occur.

      I create a small plugin to show the issue, within that plugin, in the iterator, I including a couple messages to show the recipes that are being iterated. As you can see here a few of the recipes are showing a result of AIR

      Code:

      List<Recipe> backup = new ArrayList<>();
      
      Iterator<Recipe> a = this.getServer().recipeIterator();
      
      while (a.hasNext()) {
          Recipe recipe = a.next();
          backup.add(recipe);
          Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "Recipe Iterator: " + recipe);
          Bukkit.getConsoleSender().sendMessage(ChatColor.GRAY + "Recipe Iterator: " + recipe.getResult());
      }
      

      Example of a few recipes being sent to the console with a result of air:

      [22:53:39] [Server thread/INFO]: Recipe Iterator: org.bukkit.craftbukkit.v1_14_R1.inventory.CraftShapelessRecipe@86fb598
      [22:53:39] [Server thread/INFO]: Recipe Iterator: ItemStack{AIR x 0}
      [22:53:39] [Server thread/INFO]: Recipe Iterator: org.bukkit.craftbukkit.v1_14_R1.inventory.CraftShapelessRecipe@e351942
      [22:53:39] [Server thread/INFO]: Recipe Iterator: ItemStack{AIR x 0}
      [22:53:39] [Server thread/INFO]: Recipe Iterator: org.bukkit.craftbukkit.v1_14_R1.inventory.CraftShapelessRecipe@273aedb4
      [22:53:39] [Server thread/INFO]: Recipe Iterator: ItemStack{AIR x 0}
      

      I understand that iterating all recipes, creating a new list of them, removing certain recipes from the list, cleaning all the servers recipes and adding them back in, things may not go as planned, but I figured I would report this incase this can be fixed.

      Maybe a suggestion would be, include a method for removing recipes.

      I had issues with this on 1.13.2 as well as 1.14. Craftbukkit and Spigot both give the same outcome.

      Can not be tested on vanilla, as this is a plugin using the API causing the issue.

      I included my sample plugin, as well as the source code for it, and I also included a couple pictures, 1 of the recipe book in the crafting table showing the "air" recipes, 1 of the client showing a crash. 

      I also included the client crash report, if that helps any.

      Im also including the server log, if that helps any as well (Just shows the recipes being iterated, no errors though)

        1. crash.txt
          3 kB
        2. latest.log
          169 kB
        3. RecipeTest.jar
          3 kB
        4. RecipeTest.java
          1 kB
        5. Screen Shot 2019-05-01 at 10.49.07 PM.png
          Screen Shot 2019-05-01 at 10.49.07 PM.png
          109 kB
        6. Screen Shot 2019-05-01 at 10.49.20 PM.png
          Screen Shot 2019-05-01 at 10.49.20 PM.png
          111 kB

            Unassigned Unassigned
            ShaneBee Shane Bee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: