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 new file mode 100644 index 000000000..cf9b76b2d --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/ItemRewriter.java @@ -0,0 +1,111 @@ +package us.myles.ViaVersion.api.rewriters; + +import us.myles.ViaVersion.api.minecraft.item.Item; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.State; + +// If any of these methods become outdated, just create a new rewriter overriding the methods +public class ItemRewriter { + private final Protocol protocol; + private final RewriteFunction toClient; + private final RewriteFunction toServer; + + public ItemRewriter(Protocol protocol, RewriteFunction toClient, RewriteFunction toServer) { + this.protocol = protocol; + this.toClient = toClient; + this.toServer = toServer; + } + + public void registerWindowItems(Type type, int oldPacketId, int newPacketId) { + protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(type); // 1 - Window Values + + handler(itemArrayHandler(type)); + } + }); + } + + public void registerSetSlot(Type type, int oldPacketId, int newPacketId) { + protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot ID + map(type); // 2 - Slot Value + + handler(itemToClientHandler(type)); + } + }); + } + + public void registerEntityEquipment(Type type, int oldPacketId, int newPacketId) { + protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.VAR_INT); // 1 - Slot ID + map(type); // 2 - Item + + handler(itemToClientHandler(type)); + } + }); + } + + public void registerCreativeInvAction(Type type, int oldPacketId, int newPacketId) { + protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.SHORT); // 0 - Slot + map(type); // 1 - Clicked Item + + handler(itemToServerHandler(type)); + } + }); + } + + public void registerClickWindow(Type type, int oldPacketId, int newPacketId) { + protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot + map(Type.BYTE); // 2 - Button + map(Type.SHORT); // 3 - Action number + map(Type.VAR_INT); // 4 - Mode + map(type); // 5 - Clicked Item + + handler(itemToServerHandler(type)); + } + }); + } + + // Only sent to the client + public PacketHandler itemArrayHandler(Type type) { + return wrapper -> { + Item[] items = wrapper.get(type, 0); + for (Item item : items) { + toClient.rewrite(item); + } + }; + } + + public PacketHandler itemToClientHandler(Type type) { + return wrapper -> toClient.rewrite(wrapper.get(type, 0)); + } + + public PacketHandler itemToServerHandler(Type type) { + return wrapper -> toServer.rewrite(wrapper.get(type, 0)); + } + + @FunctionalInterface + public interface RewriteFunction { + + void rewrite(Item item); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java index 10a4f04b6..d484a9e78 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/MetadataRewriter.java @@ -15,11 +15,12 @@ import us.myles.ViaVersion.packets.State; import java.util.*; import java.util.logging.Logger; -public abstract class MetadataRewriter extends Rewriter { +public abstract class MetadataRewriter { private final Class entityTrackerClass; + private final Protocol protocol; - protected MetadataRewriter(T protocol, Class entityTrackerClass) { - super(protocol); + protected MetadataRewriter(Protocol protocol, Class entityTrackerClass) { + this.protocol = protocol; this.entityTrackerClass = entityTrackerClass; protocol.put(this); } @@ -53,7 +54,7 @@ public abstract class MetadataRewriter extends Rewriter { } public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type> oldMetaType, Type> newMetaType) { - getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity ID @@ -146,7 +147,7 @@ public abstract class MetadataRewriter extends Rewriter { } public void registerEntityDestroy(int oldPacketId, int newPacketId) { - getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { + protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT_ARRAY); // 0 - Entity ids diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/Rewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/Rewriter.java deleted file mode 100644 index 44da9a3d3..000000000 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/Rewriter.java +++ /dev/null @@ -1,15 +0,0 @@ -package us.myles.ViaVersion.api.rewriters; - -import us.myles.ViaVersion.api.protocol.Protocol; - -public abstract class Rewriter { - protected final T protocol; - - protected Rewriter(T protocol) { - this.protocol = protocol; - } - - public T getProtocol() { - return protocol; - } -} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java index b181854d9..c5c3c1c20 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; -public class MetadataRewriter1_11To1_10 extends MetadataRewriter { +public class MetadataRewriter1_11To1_10 extends MetadataRewriter { public MetadataRewriter1_11To1_10(Protocol1_11To1_10 protocol) { super(protocol, EntityTracker1_11.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/packets/InventoryPackets.java index 2622fdbb5..4c731116f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/packets/InventoryPackets.java @@ -1,73 +1,27 @@ package us.myles.ViaVersion.protocols.protocol1_11to1_10.packets; import us.myles.ViaVersion.api.PacketWrapper; -import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter; import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10; public class InventoryPackets { + public static void register(Protocol1_11To1_10 protocol) { - /* - Incoming packets - */ + ItemRewriter itemRewriter = new ItemRewriter(protocol, EntityIdRewriter::toClientItem, EntityIdRewriter::toServerItem); // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.ITEM); // 2 - Slot Value - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.ITEM, 0); - EntityIdRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16); // Window items packet - protocol.registerOutgoing(State.PLAY, 0x14, 0x14, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.ITEM_ARRAY); // 1 - Window Values - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0); - for (Item stack : stacks) - EntityIdRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14); // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x3C, 0x3C, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.ITEM); // 2 - Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.ITEM, 0); - EntityIdRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C); // Plugin message Packet -> Trading protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() { @@ -99,49 +53,12 @@ public class InventoryPackets { }); } }); - - /* - Incoming packets - */ + // Click window packet - protocol.registerIncoming(State.PLAY, 0x07, 0x07, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.ITEM); // 5 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.ITEM, 0); - EntityIdRewriter.toServerItem(item); - } - }); - } - } - ); + itemRewriter.registerClickWindow(Type.ITEM, 0x07, 0x07); // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x18, 0x18, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.ITEM); // 1 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.ITEM, 0); - EntityIdRewriter.toServerItem(item); - } - }); - } - } - ); + itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java index 0a85b80a3..b7c30fe3c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/metadata/MetadataRewriter1_12To1_11_1.java @@ -12,7 +12,7 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.storage.EntityTracker1 import java.util.List; -public class MetadataRewriter1_12To1_11_1 extends MetadataRewriter { +public class MetadataRewriter1_12To1_11_1 extends MetadataRewriter { public MetadataRewriter1_12To1_11_1(Protocol1_12To1_11_1 protocol) { super(protocol, EntityTracker1_12.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java index 6f2ab9d5e..907770a17 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/packets/InventoryPackets.java @@ -5,6 +5,7 @@ import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter; @@ -12,64 +13,18 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider; public class InventoryPackets { + public static void register(Protocol1_12To1_11_1 protocol) { - /* - Outgoing packets - */ + ItemRewriter itemRewriter = new ItemRewriter(protocol, BedRewriter::toClientItem, BedRewriter::toServerItem); // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.ITEM); // 2 - Slot Value - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.ITEM, 0); - BedRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16); // Window items packet - protocol.registerOutgoing(State.PLAY, 0x14, 0x14, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.ITEM_ARRAY); // 1 - Window Values - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0); - for (Item stack : stacks) - BedRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14); // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x3C, 0x3E, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.ITEM); // 2 - Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.ITEM, 0); - BedRewriter.toClientItem(stack); - } - }); - } - }); + itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3E); // Plugin message Packet -> Trading protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() { @@ -101,10 +56,7 @@ public class InventoryPackets { }); } }); - - /* - Incoming packets - */ + // Click window packet protocol.registerIncoming(State.PLAY, 0x07, 0x08, new PacketRemapper() { @@ -148,21 +100,6 @@ public class InventoryPackets { ); // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x18, 0x1b, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.ITEM); // 1 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.ITEM, 0); - BedRewriter.toServerItem(item); - } - }); - } - } - ); + itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x1b); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/metadata/MetadataRewriter1_13_1To1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/metadata/MetadataRewriter1_13_1To1_13.java index 9cd178ac9..c8364df67 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/metadata/MetadataRewriter1_13_1To1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/metadata/MetadataRewriter1_13_1To1_13.java @@ -13,7 +13,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1 import java.util.List; -public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter { +public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter { public MetadataRewriter1_13_1To1_13(Protocol1_13_1To1_13 protocol) { super(protocol, EntityTracker1_13.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java index ae67cb6e9..e7408b318 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java @@ -5,52 +5,20 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; public class InventoryPackets { public static void register(Protocol protocol) { - - /* - Outgoing packets - */ + ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.FLAT_ITEM, 0); - toClient(stack); - } - }); - } - }); + itemRewriter.registerSetSlot(Type.FLAT_ITEM, 0x17, 0x17); // Window items packet - protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.FLAT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.FLAT_ITEM_ARRAY, 0); - for (Item stack : stacks) - toClient(stack); - } - }); - } - }); + itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, 0x15, 0x15); // Plugin message protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { @@ -88,22 +56,7 @@ public class InventoryPackets { }); // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 2 - Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.FLAT_ITEM, 0); - toClient(stack); - } - }); - } - }); + itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42); // Declare Recipes protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() { @@ -155,49 +108,11 @@ public class InventoryPackets { }); - /* - Incoming packets - */ - // Click window packet - protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.FLAT_ITEM, 0); - toServer(item); - } - }); - } - } - ); + itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08); // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.FLAT_ITEM, 0); - toServer(item); - } - }); - } - } - ); + itemRewriter.registerCreativeInvAction(Type.FLAT_ITEM, 0x24, 0x24); } public static void toClient(Item item) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java index 6ea931ea8..750f75eba 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java @@ -10,11 +10,6 @@ import us.myles.ViaVersion.packets.State; public class InventoryPackets { public static void register(Protocol protocol) { - - /* - Outgoing packets - */ - // Set slot packet protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { @Override @@ -118,11 +113,6 @@ public class InventoryPackets { } }); - - /* - Incoming packets - */ - // Click window packet protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java index 23eabbd15..e48420fca 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java @@ -19,7 +19,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1 import java.util.List; import java.util.Map; -public class MetadataRewriter1_13To1_12_2 extends MetadataRewriter { +public class MetadataRewriter1_13To1_12_2 extends MetadataRewriter { public MetadataRewriter1_13To1_12_2(Protocol1_13To1_12_2 protocol) { super(protocol, EntityTracker1_13.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index 8ece466d4..3e2798296 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -10,9 +10,11 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SoundSource; @@ -25,14 +27,10 @@ import java.util.Locale; import java.util.Optional; public class InventoryPackets { - private static String NBT_TAG_NAME; + private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_13To1_12_2.class.getSimpleName(); public static void register(Protocol protocol) { - NBT_TAG_NAME = "ViaVersion|" + protocol.getClass().getSimpleName(); - - /* - Outgoing packets - */ + ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); // Set slot packet protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() { @@ -42,13 +40,7 @@ public class InventoryPackets { map(Type.SHORT); // 1 - Slot ID map(Type.ITEM, Type.FLAT_ITEM); // 2 - Slot Value - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.FLAT_ITEM, 0); - toClient(stack); - } - }); + handler(itemRewriter.itemToClientHandler(Type.FLAT_ITEM)); } }); @@ -59,14 +51,7 @@ public class InventoryPackets { map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.FLAT_ITEM_ARRAY, 0); - for (Item stack : stacks) - toClient(stack); - } - }); + handler(itemRewriter.itemArrayHandler(Type.FLAT_ITEM_ARRAY)); } }); @@ -77,14 +62,13 @@ public class InventoryPackets { map(Type.UNSIGNED_BYTE); // Window id map(Type.SHORT); // Property map(Type.SHORT); // Value + handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { short property = wrapper.get(Type.SHORT, 0); if (property >= 4 && property <= 6) { // Enchantment id - wrapper.set(Type.SHORT, 1, (short) MappingData.enchantmentMappings.getNewId( - wrapper.get(Type.SHORT, 1) - )); + wrapper.set(Type.SHORT, 1, (short) MappingData.enchantmentMappings.getNewId(wrapper.get(Type.SHORT, 1))); } } }); @@ -202,42 +186,25 @@ public class InventoryPackets { map(Type.VAR_INT); // 1 - Slot ID map(Type.ITEM, Type.FLAT_ITEM); // 2 - Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item stack = wrapper.get(Type.FLAT_ITEM, 0); - toClient(stack); - } - }); + handler(itemRewriter.itemToClientHandler(Type.FLAT_ITEM)); } }); - /* - Incoming packets - */ - // Click window packet protocol.registerIncoming(State.PLAY, 0x07, 0x08, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_ITEM, Type.ITEM); // 5 - Clicked Item + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // 0 - Window ID + map(Type.SHORT); // 1 - Slot + map(Type.BYTE); // 2 - Button + map(Type.SHORT); // 3 - Action number + map(Type.VAR_INT); // 4 - Mode + map(Type.FLAT_ITEM, Type.ITEM); // 5 - Clicked Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.ITEM, 0); - toServer(item); - } - }); - } - } - ); + handler(itemRewriter.itemToServerHandler(Type.ITEM)); + } + }); // Plugin message protocol.registerIncoming(State.PLAY, 0x09, 0x0A, new PacketRemapper() { @@ -277,21 +244,14 @@ public class InventoryPackets { // Creative Inventory Action protocol.registerIncoming(State.PLAY, 0x1B, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_ITEM, Type.ITEM); // 1 - Clicked Item + @Override + public void registerMap() { + map(Type.SHORT); // 0 - Slot + map(Type.FLAT_ITEM, Type.ITEM); // 1 - Clicked Item - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item item = wrapper.get(Type.ITEM, 0); - toServer(item); - } - }); - } - } - ); + handler(itemRewriter.itemToServerHandler(Type.ITEM)); + } + }); } // TODO CLEANUP / SMARTER REWRITE SYSTEM @@ -509,9 +469,9 @@ public class InventoryPackets { case "bungeecord:main": return null; case "FML|MP": - return "fml:mp"; + return "fml:mp"; case "FML|HS": - return "fml:hs"; + return "fml:hs"; default: return old.matches("([0-9a-z_.-]+):([0-9a-z_/.-]+)") // Identifier regex ? old : null; @@ -754,9 +714,9 @@ public class InventoryPackets { case "wdl:request": return "WDL|REQUEST"; case "fml:hs": - return "FML|HS"; + return "FML|HS"; case "fml:mp": - return "FML:MP"; + return "FML:MP"; default: return newId.length() > 20 ? newId.substring(0, 20) : newId; } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java index 485363222..dba8b169b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/metadata/MetadataRewriter1_14_1To1_14.java @@ -10,7 +10,7 @@ import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1 import java.util.List; -public class MetadataRewriter1_14_1To1_14 extends MetadataRewriter { +public class MetadataRewriter1_14_1To1_14 extends MetadataRewriter { public MetadataRewriter1_14_1To1_14(Protocol1_14_1To1_14 protocol) { super(protocol, EntityTracker1_14_1.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java index 7c4f893e6..77a078cdb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java @@ -19,7 +19,7 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1 import java.util.List; -public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter { +public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter { public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) { super(protocol, EntityTracker1_14.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java index fa153eaab..348d3b3bc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java @@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; @@ -21,14 +22,11 @@ import java.util.Set; import java.util.concurrent.ThreadLocalRandom; public class InventoryPackets { - private static String NBT_TAG_NAME; + private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_14To1_13_2.class.getSimpleName(); private static final Set REMOVED_RECIPE_TYPES = Sets.newHashSet("crafting_special_banneraddpattern", "crafting_special_repairitem"); public static void register(Protocol protocol) { - NBT_TAG_NAME = "ViaVersion|" + protocol.getClass().getSimpleName(); - /* - Outgoing packets - */ + ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); // Open Inventory protocol.registerOutgoing(State.PLAY, 0x14, -1, new PacketRemapper() { @@ -105,38 +103,10 @@ public class InventoryPackets { }); // Window items packet - protocol.registerOutgoing(State.PLAY, 0x15, 0x14, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0); - for (Item stack : stacks) toClient(stack); - } - }); - } - }); + itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14); // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x17, 0x16, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16); // Plugin message protocol.registerOutgoing(State.PLAY, 0x19, 0x18, new PacketRemapper() { @@ -192,21 +162,7 @@ public class InventoryPackets { }); // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x42, 0x46, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x42, 0x46); // Declare Recipes protocol.registerOutgoing(State.PLAY, 0x54, 0x5A, new PacketRemapper() { @@ -259,29 +215,8 @@ public class InventoryPackets { }); - /* - Incoming packets - */ - // Click window packet - protocol.registerIncoming(State.PLAY, 0x08, 0x09, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x08, 0x09); // Select trade protocol.registerIncoming(State.PLAY, 0x1F, 0x21, new PacketRemapper() { @@ -307,20 +242,7 @@ public class InventoryPackets { }); // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x24, 0x26, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x24, 0x26); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java index 3d84e05ec..99165d5cd 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java @@ -14,7 +14,7 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1 import java.util.List; -public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter { +public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter { public MetadataRewriter1_15To1_14_4(Protocol1_15To1_14_4 protocol) { super(protocol, EntityTracker1_15.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java index efa714838..925d0699d 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java @@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; @@ -13,22 +14,10 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; public class InventoryPackets { public static void register(Protocol protocol) { - // Window items packet - protocol.registerOutgoing(State.PLAY, 0x14, 0x15, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values + ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0); - for (Item stack : stacks) toClient(stack); - } - }); - } - }); + // Window items packet + itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15); // Trade list packet protocol.registerOutgoing(State.PLAY, 0x27, 0x28, new PacketRemapper() { @@ -70,38 +59,10 @@ public class InventoryPackets { }); // Set slot packet - protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x16, 0x17); // Entity Equipment Packet - protocol.registerOutgoing(State.PLAY, 0x46, 0x47, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x46, 0x47); // Declare Recipes protocol.registerOutgoing(State.PLAY, 0x5A, 0x5B, new PacketRemapper() { @@ -171,40 +132,10 @@ public class InventoryPackets { }); // Click window packet - protocol.registerIncoming(State.PLAY, 0x09, 0x09, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.UNSIGNED_BYTE); // 0 - Window ID - map(Type.SHORT); // 1 - Slot - map(Type.BYTE); // 2 - Button - map(Type.SHORT); // 3 - Action number - map(Type.VAR_INT); // 4 - Mode - map(Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09); // Creative Inventory Action - protocol.registerIncoming(State.PLAY, 0x26, 0x26, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.SHORT); // 0 - Slot - map(Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); - } - }); - } - }); + itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26); } public static void toClient(Item item) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java index 5925c9d35..10f626a05 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/metadata/MetadataRewriter1_9To1_8.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; -public class MetadataRewriter1_9To1_8 extends MetadataRewriter { +public class MetadataRewriter1_9To1_8 extends MetadataRewriter { public MetadataRewriter1_9To1_8(Protocol1_9To1_8 protocol) { super(protocol, EntityTracker1_9.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/InventoryPackets.java index e28a36afe..50ec5fd50 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/InventoryPackets.java @@ -14,6 +14,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker; public class InventoryPackets { + public static void register(Protocol protocol) { // Window Property Packet protocol.registerOutgoing(State.PLAY, 0x31, 0x15, new PacketRemapper() { @@ -334,7 +335,5 @@ public class InventoryPackets { protocol.registerIncoming(State.PLAY, 0x0F, 0x05); // Confirm Transaction Packet protocol.registerIncoming(State.PLAY, 0x11, 0x06); // Enchant Item Packet - - } }