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

Recipe-Book clicks fires ClassCastEx. after reload

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-5eb8a94-18b8ae1 (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
    • Yes

       

      Code to reproduce (used in onEnable)

      addRecipes(Material.COAL,1);
      addRecipes(Material.IRON_INGOT,2);
      addRecipes(Material.GOLD_INGOT,3);
      addRecipes(Material.DIAMOND,4);
      addRecipes(Material.EMERALD,5);
      addRecipes(Material.NETHERITE_INGOT,6); 
      
      public void addRecipes(Material additionalIngredient, int tier) {
      
          ShapedRecipe shapedRecipe = new ShapedRecipe(new NamespacedKey(this, "tier"+tier), new ItemStack(Material.BOW));
          shapedRecipe.shape("aaa",
                             "aba",
                             "aaa");
          shapedRecipe.setIngredient('a', additionalIngredient);
          shapedRecipe.setIngredient('b', new RecipeChoice.MaterialChoice(Material.BUNDLE));
          Bukkit.addRecipe(shapedRecipe);
      
      }

      If you add only tier first line with Coal for example will work as aspected, but adding more then just one will cause in following error after clicking some random stuff in the recipe book:

      [19:25:10] [Server thread/ERROR]: Failed to handle packet PacketPlayInAutoRecipe[containerId=46, recipe=RecipeDisplayId[index=1265], useMaxItems=false], suppressing error
      java.lang.ClassCastException: class net.minecraft.world.item.crafting.CraftingInput cannot be cast to class net.minecraft.world.item.crafting.SingleRecipeInput (net.minecraft.world.item.crafting.CraftingInput and net.minecraft.world.item.crafting.SingleRecipeInput are in unnamed module of loader java.net.URLClassLoader @736e9adb)
              at net.minecraft.world.item.crafting.RecipeSingleItem.a(SourceFile:15) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.world.item.crafting.CraftingManager.a(CraftingManager.java:190) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.world.inventory.ContainerWorkbench.a(ContainerWorkbench.java:61) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.world.inventory.ContainerWorkbench.a(ContainerWorkbench.java:104) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.world.inventory.AbstractCraftingMenu.a(AbstractCraftingMenu.java:71) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2909) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.network.protocol.game.PacketPlayInAutoRecipe.a(SourceFile:29) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.network.protocol.game.PacketPlayInAutoRecipe.a(SourceFile:10) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:35) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:164) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1319) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:210) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.util.thread.IAsyncTaskHandler.B(SourceFile:138) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.bv(MinecraftServer.java:1298) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.B(MinecraftServer.java:1291) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:147) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1248) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.x_(MinecraftServer.java:1258) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1101) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[spigot-1.21.3-R0.1-SNAPSHOT.jar:dev-Spigot-5eb8a94-6029040]
              at java.base/java.lang.Thread.run(Thread.java:1575) [?:?] 

      The image below will show the current setup that i had in the recipe book.

      When clicking on the Heavy Weighted Pressure Plate it also shows this random other recipe of a chisseled bookshelf

       

            Unassigned Unassigned
            FreeSoccerHDX FreeSoccerHDX
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: