From 55b4f6c0801361533b0d62bc8bf18a21431af674 Mon Sep 17 00:00:00 2001 From: Marco Neuhaus Date: Wed, 23 Jan 2019 13:31:05 +0100 Subject: [PATCH] fix rewrite --- .../Protocol1_12_2To1_13.java | 7 ++- .../packets/BlockItemPackets1_13.java | 44 +++---------------- .../packets/EntityPackets1_13.java | 2 +- .../packets/PlayerPacket1_13.java | 8 ++-- 4 files changed, 16 insertions(+), 45 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java index a41e4bfe..0c89efe7 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java @@ -10,6 +10,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13; +import lombok.Getter; import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings; @@ -29,7 +30,11 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; +@Getter public class Protocol1_12_2To1_13 extends BackwardsProtocol { + + private BlockItemPackets1_13 blockItemPackets; + static { BackwardsMappings.init(); PaintingMapping.init(); @@ -38,7 +43,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { @Override protected void registerPackets() { - new BlockItemPackets1_13().register(this); + (blockItemPackets = new BlockItemPackets1_13()).register(this); new EntityPackets1_13().register(this); new PlayerPacket1_13().register(this); new SoundPackets1_13().register(this); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index 6be019eb..d9ecd5ec 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -32,7 +32,6 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; 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.SpawnEggRewriter; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @@ -56,39 +55,6 @@ public class BlockItemPackets1_13 extends BlockItemRewriter { // Rewrite items else if (typeId == 6) { meta.setMetaType(MetaType1_12.Slot); - BlockItemPackets1_13.toClient((Item) meta.getValue()); + getProtocol().getBlockItemPackets().handleItemToClient((Item) meta.getValue()); } // Discontinue particles diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 899ce5a8..44edf8ff 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -34,18 +34,18 @@ public class PlayerPacket1_13 extends Rewriter { for (int i = 0; i < size; i++) { //Input Item Item input = wrapper.read(Type.FLAT_ITEM); - BlockItemPackets1_13.toClient(input); + getProtocol().getBlockItemPackets().handleItemToClient(input); wrapper.write(Type.ITEM, input); //Output Item Item output = wrapper.read(Type.FLAT_ITEM); - BlockItemPackets1_13.toClient(output); + getProtocol().getBlockItemPackets().handleItemToClient(output); wrapper.write(Type.ITEM, output); boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item if (secondItem) { //Second Item Item second = wrapper.read(Type.FLAT_ITEM); - BlockItemPackets1_13.toClient(second); + getProtocol().getBlockItemPackets().handleItemToClient(second); wrapper.write(Type.ITEM, second); } @@ -207,7 +207,7 @@ public class PlayerPacket1_13 extends Rewriter { if (channel.equals("MC|BSign") || channel.equals("MC|BEdit")) { wrapper.setId(0x0B); Item book = wrapper.read(Type.ITEM); - BlockItemPackets1_13.toServer(book); + getProtocol().getBlockItemPackets().handleItemToServer(book); wrapper.write(Type.FLAT_ITEM, book); boolean signing = channel.equals("MC|BSign"); wrapper.write(Type.BOOLEAN, signing);