From a6ff477b8a2d19b4092b61fca7e0e6da803f73c6 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 5 Oct 2024 16:08:52 +0200 Subject: [PATCH] Implement clientbound ghost recipe, fix null recipe groups --- .../BlockItemPacketRewriter1_21_2.java | 9 +++--- .../rewriter/RecipeRewriter1_21_2.java | 31 ++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java index df0d9301d..fe3c4fbcb 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java @@ -125,14 +125,15 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< protocol.registerClientbound(ClientboundPackets1_21.PLACE_GHOST_RECIPE, wrapper -> { this.updateContainerId(wrapper); - // TODO - if (true) { + final String recipeKey = wrapper.read(Types.STRING); + final RecipeRewriter1_21_2.Recipe recipe = wrapper.user().get(RecipeRewriter1_21_2.class).recipe(recipeKey); + if (recipe == null) { wrapper.cancel(); return; } - final String recipe = wrapper.read(Types.STRING); - wrapper.write(Types.VAR_INT, recipeDisplay(recipe)); + wrapper.write(Types.VAR_INT, recipe.recipeDisplayId()); + recipe.writeRecipeDisplay(wrapper); }); protocol.registerServerbound(ServerboundPackets1_21_2.PLACE_RECIPE, wrapper -> { this.updateContainerIdServerbound(wrapper); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/RecipeRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/RecipeRewriter1_21_2.java index 24cf5376b..f9561f0a2 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/RecipeRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/RecipeRewriter1_21_2.java @@ -71,7 +71,7 @@ final class RecipeRewriter1_21_2 extends RecipeRewriter1_20_3