-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.21.3 - RecipeBook click ignores ExactChoice (Spigot bug) #4108
Comments
Notes: Citation from the Spigot forum.
Example code: {
org.bukkit.inventory.ShapedRecipe recipe = new org.bukkit.inventory.ShapedRecipe(new NamespacedKey("test", "test"), new org.bukkit.inventory.ItemStack(Material.BARRIER));
recipe.shape( "ccc", "xix", "xix");
org.bukkit.inventory.ItemStack exact = new org.bukkit.inventory.ItemStack(Material.DIAMOND);
ItemMeta meta = exact.getItemMeta();
meta.setDisplayName("test item");
exact.setItemMeta(meta);
recipe.setIngredient('c', new RecipeChoice.ExactChoice(exact));
recipe.setIngredient('i', new RecipeChoice.MaterialChoice(Material.STICK));
org.bukkit.inventory.ItemStack aaa = exact.clone();
aaa.setAmount(32);
Bukkit.getPlayer("LoneDev").getInventory().addItem(aaa);
try
{
Bukkit.addRecipe(recipe);
}
catch(IllegalStateException e) // The recipe already exists, so I remove it and re-add it.
{
Bukkit.removeRecipe(recipe.getKey());
Bukkit.addRecipe(recipe);
}
} If you click on the recipe button you clearly see vanilla items added instead of the renamed Diamond. If you manually put the correct renamed Diamond it works as intended. You can craft the Barrier. Because of this I have to do some magic stuff on the packet level. Even if you provide the correct recipe to handlePlacement, you will get the wrong matrix, of another recipe. RecipeBookMenu.PostPlaceAction postPlaceAction = bookMenu.handlePlacement(...) // ServerGamePacketListenerImpl#handlePlaceRecipe(...)
ServerPlayer serverPlayer = ((CraftPlayer) e.getPlayer()).getHandle();
AbstractContainerMenu containerMenu = serverPlayer.containerMenu;
if (containerMenu instanceof RecipeBookMenu bookMenu)
{
ServerLevel serverLevel = ((CraftWorld) e.getPlayer().getWorld()).getHandle();
Scheduler.sync(() -> {
RecipeBookMenu.PostPlaceAction postPlaceAction = bookMenu.handlePlacement(handle.useMaxItems(), false, recipeHolder, serverLevel, serverPlayer.getInventory());
if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE)
{
serverPlayer.connection.send(new ClientboundPlaceGhostRecipePacket(serverPlayer.containerMenu.containerId, recipeFromDisplay.display().display()));
}
});
} |
After some tests seems:
Paper has some patches for ExactChoice correct matching on 1.21.1 here. Anyway seems 1.21.3 client changed some stuff so this might not be fixable completely like it was on 1.21.1. In the meantime I opened an [issue report on the Spigot Jira, as I think this should be fixed also on Spigot. I opened an issue also on Paper GitHub, maybe they will fix it before Spigot: 1.21.1Minecraft.1.21.1.-.Multiplayer.3rd-party.Server.2024-11-08.11-03-35.2.mp41.21.3Minecraft.1.21.3.-.Multiplayer.3rd-party.Server.2024-11-08.11-03-15.2.1.mp4 |
Note: // net.minecraft.client.gui.screens.recipebook.RecipeBookComponent
// handlePlaceRecipe calls ServerboundPlaceRecipePacket
private boolean tryPlaceRecipe(RecipeCollection recipeCollection, RecipeDisplayId recipeDisplayId) {
if (!recipeCollection.isCraftable(recipeDisplayId) && recipeDisplayId.equals(this.lastPlacedRecipe)) {
return false;
} else {
this.lastPlacedRecipe = recipeDisplayId;
this.ghostSlots.clear();
this.minecraft.gameMode.handlePlaceRecipe(this.minecraft.player.containerMenu.containerId, recipeDisplayId, Screen.hasShiftDown());
return true;
}
} Attaching a debugger to the client shows that 1.21.3 doesn't send the |
Workaround implemented, but sadly doesn't completely fix the issue. Known issues:You can't increment the number of crafted items by clicking or shift-clicking on the recipe.
Check the video to understand more. Minecraft.1.21.3.-.Multiplayer.3rd-party.Server.2024-11-08.17-27-07.2.mp4 |
The text was updated successfully, but these errors were encountered: