[SPIGOT-7940] Recipe-Book clicks fires ClassCastEx. after reload Created: 31/Oct/24  Updated: 25/Dec/24  Resolved: 02/Nov/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: FreeSoccerHDX Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Attachments: PNG File Screenshot 2024-10-31 192712.png    
Version: This server is running CraftBukkit version dev-Spigot-5eb8a94-18b8ae1 (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

 

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

 



 Comments   
Comment by FreeSoccerHDX [ 31/Oct/24 ]
@Override
public void onDisable() {
    Bukkit.removeRecipe(new NamespacedKey(this, "tier1"));
    Bukkit.removeRecipe(new NamespacedKey(this, "tier2"));
    Bukkit.removeRecipe(new NamespacedKey(this, "tier3"));
    Bukkit.removeRecipe(new NamespacedKey(this, "tier4"));
    Bukkit.removeRecipe(new NamespacedKey(this, "tier5"));
    Bukkit.removeRecipe(new NamespacedKey(this, "tier6"));
} 

related code, before reloading everything seems to work fine

after reload: the recipe book error starts

Generated at Sat Dec 13 15:23:03 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.