From 67c5e78e7bc8afbff19483355c735670ec1c1626 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 2 Jul 2020 00:18:33 +0200 Subject: [PATCH] Cleanup declare recipe, trade list, and advancement packets --- .../api/rewriters/ItemRewriter.java | 73 +++++++++++- .../api/rewriters/RecipeRewriter.java | 36 ++++++ .../Protocol1_13_1To1_13.java | 42 ------- .../packets/InventoryPackets.java | 1 + .../Protocol1_13_2To1_13_1.java | 3 +- .../Protocol1_14To1_13_2.java | 41 ------- .../data/RecipeRewriter1_14.java | 66 +++++++++++ .../packets/InventoryPackets.java | 1 + .../Protocol1_15To1_14_4.java | 43 ------- .../data/RecipeRewriter1_15.java | 46 +++++++ .../packets/InventoryPackets.java | 112 +----------------- .../Protocol1_16_2To1_16_1.java | 38 ------ .../packets/InventoryPackets.java | 110 +---------------- .../Protocol1_16To1_15_2.java | 38 ------ .../data/RecipeRewriter1_16.java | 51 ++++++++ .../packets/InventoryPackets.java | 98 +-------------- 16 files changed, 289 insertions(+), 510 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/api/rewriters/RecipeRewriter.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/data/RecipeRewriter1_14.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/data/RecipeRewriter1_15.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/data/RecipeRewriter1_16.java diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/ItemRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/ItemRewriter.java index d83af1076..df7cfb31b 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/ItemRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/ItemRewriter.java @@ -70,7 +70,7 @@ public class ItemRewriter { byte slot; do { slot = wrapper.passthrough(Type.BYTE); - // & 0x7F into an extra variable if slot is needed + // & 0x7F into an extra variable if slot is needed toClient.rewrite(wrapper.passthrough(type)); } while ((slot & 0xFFFFFF80) != 0); }); @@ -118,6 +118,77 @@ public class ItemRewriter { }); } + // 1.14.4+ + public void registerTradeList(ClientboundPacketType packetType, Type type) { + protocol.registerOutgoing(packetType, new PacketRemapper() { + @Override + public void registerMap() { + handler(wrapper -> { + wrapper.passthrough(Type.VAR_INT); + int size = wrapper.passthrough(Type.UNSIGNED_BYTE); + for (int i = 0; i < size; i++) { + toClient.rewrite(wrapper.passthrough(type)); // Input + toClient.rewrite(wrapper.passthrough(type)); // Output + + if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item + toClient.rewrite(wrapper.passthrough(type)); // Second Item + } + + wrapper.passthrough(Type.BOOLEAN); // Trade disabled + wrapper.passthrough(Type.INT); // Number of tools uses + wrapper.passthrough(Type.INT); // Maximum number of trade uses + + wrapper.passthrough(Type.INT); // XP + wrapper.passthrough(Type.INT); // Special price + wrapper.passthrough(Type.FLOAT); // Price multiplier + wrapper.passthrough(Type.INT); // Demand + } + //... + }); + } + }); + } + + public void registerAdvancements(ClientboundPacketType packetType, Type type) { + protocol.registerOutgoing(packetType, new PacketRemapper() { + @Override + public void registerMap() { + handler(wrapper -> { + wrapper.passthrough(Type.BOOLEAN); // Reset/clear + int size = wrapper.passthrough(Type.VAR_INT); // Mapping size + for (int i = 0; i < size; i++) { + wrapper.passthrough(Type.STRING); // Identifier + + // Parent + if (wrapper.passthrough(Type.BOOLEAN)) + wrapper.passthrough(Type.STRING); + + // Display data + if (wrapper.passthrough(Type.BOOLEAN)) { + wrapper.passthrough(Type.COMPONENT); // Title + wrapper.passthrough(Type.COMPONENT); // Description + toClient.rewrite(wrapper.passthrough(type)); // Icon + wrapper.passthrough(Type.VAR_INT); // Frame type + int flags = wrapper.passthrough(Type.INT); // Flags + if ((flags & 1) != 0) { + wrapper.passthrough(Type.STRING); // Background texture + } + wrapper.passthrough(Type.FLOAT); // X + wrapper.passthrough(Type.FLOAT); // Y + } + + wrapper.passthrough(Type.STRING_ARRAY); // Criteria + + int arrayLength = wrapper.passthrough(Type.VAR_INT); + for (int array = 0; array < arrayLength; array++) { + wrapper.passthrough(Type.STRING_ARRAY); // String array + } + } + }); + } + }); + } + // Only sent to the client public PacketHandler itemArrayHandler(Type type) { return wrapper -> { diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/RecipeRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/RecipeRewriter.java new file mode 100644 index 000000000..d8f5b290d --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/RecipeRewriter.java @@ -0,0 +1,36 @@ +package us.myles.ViaVersion.api.rewriters; + +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.protocol.ClientboundPacketType; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; + +public abstract class RecipeRewriter { + + protected final Protocol protocol; + protected final ItemRewriter.RewriteFunction rewriter; + + protected RecipeRewriter(Protocol protocol, ItemRewriter.RewriteFunction rewriter) { + this.protocol = protocol; + this.rewriter = rewriter; + } + + public abstract void handle(PacketWrapper wrapper, String type) throws Exception; + + public void registerDefaultHandler(ClientboundPacketType packetType) { + protocol.registerOutgoing(packetType, new PacketRemapper() { + @Override + public void registerMap() { + handler(wrapper -> { + int size = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < size; i++) { + String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); + String id = wrapper.passthrough(Type.STRING); // Recipe Identifier + handle(wrapper, type); + } + }); + } + }); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java index eeb39ef3f..40239ab04 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java @@ -118,48 +118,6 @@ public class Protocol1_13_1To1_13 extends Protocol { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size - - for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - - // Parent - if (wrapper.passthrough(Type.BOOLEAN)) - wrapper.passthrough(Type.STRING); - - // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description - InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags - if ((flags & 1) != 0) - wrapper.passthrough(Type.STRING); // Background texture - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y - } - - wrapper.passthrough(Type.STRING_ARRAY); // Criteria - - int arrayLength = wrapper.passthrough(Type.VAR_INT); - for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array - } - } - }); - } - }); - // Recipe book data has been split into 2 separate packets registerIncoming(ServerboundPackets1_16_2.RECIPE_BOOK_DATA, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java index f6f95dd50..4da15cd53 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16_2to1_16_1/packets/InventoryPackets.java @@ -9,6 +9,7 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16 import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; +import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; public class InventoryPackets { @@ -17,6 +18,10 @@ public class InventoryPackets { itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); + itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); + itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM); + itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); + itemRewriter.registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); protocol.registerOutgoing(ClientboundPackets1_16.UNLOCK_RECIPES, new PacketRemapper() { @Override @@ -36,110 +41,7 @@ public class InventoryPackets { } }); - protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() { - @Override - public void registerMap() { - handler(wrapper -> { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); - for (int i = 0; i < size; i++) { - Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); - toClient(input); - - Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); - toClient(output); - - if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Second Item - } - - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses - - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.INT); - } - - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.BOOLEAN); - }); - } - }); - - itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM); - itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); - - protocol.registerOutgoing(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() { - @Override - public void registerMap() { - handler(wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); - for (int i = 0; i < size; i++) { - String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); - String id = wrapper.passthrough(Type.STRING); - switch (type) { - case "crafting_shapeless": { - wrapper.passthrough(Type.STRING); // Group - - int ingredientsNo = wrapper.passthrough(Type.VAR_INT); - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - break; - } - case "crafting_shaped": { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - break; - } - case "blasting": - case "smoking": - case "campfire_cooking": - case "smelting": { - wrapper.passthrough(Type.STRING); // Group - - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - wrapper.passthrough(Type.FLOAT); // EXP - - wrapper.passthrough(Type.VAR_INT); // Cooking time - break; - } - case "stonecutting": { - wrapper.passthrough(Type.STRING); - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - break; - } - case "smithing": { - wrapper.passthrough(Type.STRING); - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); - for (Item item : items) toClient(item); - items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - break; - } - } - } - }); - } - }); + new RecipeRewriter1_16(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES); itemRewriter.registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java index b27aba8c3..a990d2d21 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java @@ -120,44 +120,6 @@ public class Protocol1_16To1_15_2 extends Protocol { - wrapper.passthrough(Type.BOOLEAN); // Reset/clear - int size = wrapper.passthrough(Type.VAR_INT); // Mapping size - - for (int i = 0; i < size; i++) { - wrapper.passthrough(Type.STRING); // Identifier - - // Parent - if (wrapper.passthrough(Type.BOOLEAN)) - wrapper.passthrough(Type.STRING); - - // Display data - if (wrapper.passthrough(Type.BOOLEAN)) { - wrapper.passthrough(Type.COMPONENT); // Title - wrapper.passthrough(Type.COMPONENT); // Description - InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon - wrapper.passthrough(Type.VAR_INT); // Frame type - int flags = wrapper.passthrough(Type.INT); // Flags - if ((flags & 1) != 0) - wrapper.passthrough(Type.STRING); // Background texture - wrapper.passthrough(Type.FLOAT); // X - wrapper.passthrough(Type.FLOAT); // Y - } - - wrapper.passthrough(Type.STRING_ARRAY); // Criteria - - int arrayLength = wrapper.passthrough(Type.VAR_INT); - for (int array = 0; array < arrayLength; array++) { - wrapper.passthrough(Type.STRING_ARRAY); // String array - } - } - }); - } - }); - registerIncoming(ServerboundPackets1_16.INTERACT_ENTITY, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/data/RecipeRewriter1_16.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/data/RecipeRewriter1_16.java new file mode 100644 index 000000000..06cb88370 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/data/RecipeRewriter1_16.java @@ -0,0 +1,51 @@ +package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data; + +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15; + +public class RecipeRewriter1_16 extends RecipeRewriter1_15 { + + public RecipeRewriter1_16(Protocol protocol, ItemRewriter.RewriteFunction rewriter) { + super(protocol, rewriter); + } + + @Override + public void handle(PacketWrapper wrapper, String type) throws Exception { + switch (type) { + case "crafting_shapeless": + handleCraftingShapeless(wrapper); + break; + case "crafting_shaped": + handleCraftingShaped(wrapper); + break; + case "blasting": + case "smoking": + case "campfire_cooking": + case "smelting": + handleSmelting(wrapper); + break; + case "stonecutting": + handleStonecutting(wrapper); + break; + case "smithing": // new + handleSmithing(wrapper); + break; + } + } + + public void handleSmithing(PacketWrapper wrapper) throws Exception { + Item[] baseIngredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); + for (Item item : baseIngredients) { + rewriter.rewrite(item); + } + Item[] ingredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); + for (Item item : ingredients) { + rewriter.rewrite(item); + } + rewriter.rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java index e21a8d11c..4bc322390 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java @@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.types.UUIDIntArrayType; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.RecipeRewriter1_15; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData; @@ -58,43 +59,9 @@ public class InventoryPackets { itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); - - protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() { - @Override - public void registerMap() { - handler(wrapper -> { - wrapper.passthrough(Type.VAR_INT); - int size = wrapper.passthrough(Type.UNSIGNED_BYTE); - for (int i = 0; i < size; i++) { - Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); - toClient(input); - - Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); - toClient(output); - - if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item - // Second Item - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - } - - wrapper.passthrough(Type.BOOLEAN); // Trade disabled - wrapper.passthrough(Type.INT); // Number of tools uses - wrapper.passthrough(Type.INT); // Maximum number of trade uses - - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.INT); - wrapper.passthrough(Type.FLOAT); - wrapper.passthrough(Type.INT); - } - - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.BOOLEAN); - }); - } - }); - + itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM); + itemRewriter.registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketRemapper() { @Override @@ -109,64 +76,7 @@ public class InventoryPackets { } }); - protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() { - @Override - public void registerMap() { - handler(wrapper -> { - int size = wrapper.passthrough(Type.VAR_INT); - for (int i = 0; i < size; i++) { - String type = wrapper.passthrough(Type.STRING).replace("minecraft:", ""); - String id = wrapper.passthrough(Type.STRING); - switch (type) { - case "crafting_shapeless": { - wrapper.passthrough(Type.STRING); // Group - - int ingredientsNo = wrapper.passthrough(Type.VAR_INT); - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - break; - } - case "crafting_shaped": { - int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); - wrapper.passthrough(Type.STRING); // Group - - for (int j = 0; j < ingredientsNo; j++) { - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - } - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result - break; - } - case "blasting": - case "smoking": - case "campfire_cooking": - case "smelting": { - wrapper.passthrough(Type.STRING); // Group - - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - wrapper.passthrough(Type.FLOAT); // EXP - - wrapper.passthrough(Type.VAR_INT); // Cooking time - break; - } - case "stonecutting": { - wrapper.passthrough(Type.STRING); - Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - for (Item item : items) toClient(item); - toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); - break; - } - } - } - }); - } - }); + new RecipeRewriter1_15(protocol, InventoryPackets::toClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES); itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);