From 545ab2de7957b63aff69b2fe8b66c010065eb647 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sat, 6 Jun 2020 09:45:43 +0200 Subject: [PATCH] Enforce correct packet types with generics, 1.9 packet constant --- .../ViaVersion/api/protocol/Protocol.java | 77 +++++++++-------- .../api/protocol/SimpleProtocol.java | 24 ++++++ .../api/rewriters/ItemRewriter.java | 72 ---------------- .../api/rewriters/MetadataRewriter.java | 73 ---------------- .../Protocol1_10To1_9_3_4.java | 28 +++---- .../Protocol1_11_1To1_11.java | 9 +- .../Protocol1_11To1_10.java | 55 +++++------- .../packets/InventoryPackets.java | 24 ++---- .../Protocol1_12_1To1_12.java | 2 +- .../Protocol1_12To1_11_1.java | 26 +++--- .../packets/InventoryPackets.java | 10 +-- .../Protocol1_13_1To1_13.java | 2 +- .../Protocol1_13_2To1_13_1.java | 2 +- .../Protocol1_13To1_12_2.java | 2 +- .../Protocol1_14_1To1_14.java | 2 +- .../Protocol1_14_2To1_14_1.java | 8 +- .../Protocol1_14_3To1_14_2.java | 12 ++- .../Protocol1_14_4To1_14_3.java | 12 ++- .../Protocol1_14To1_13_2.java | 2 +- .../Protocol1_15_1To1_15.java | 8 +- .../Protocol1_15_2To1_15_1.java | 8 +- .../Protocol1_15To1_14_4.java | 2 +- .../Protocol1_16To1_15_2.java | 2 +- .../Protocol1_9_1_2To1_9_3_4.java | 36 ++++---- .../Protocol1_9_1To1_9.java | 16 ++-- .../ClientboundPackets1_9_3.java} | 8 +- .../Protocol1_9_3To1_9_1_2.java | 33 +++----- .../ServerboundPackets1_9_3.java | 37 ++++++++ .../ClientboundPackets1_9.java | 84 +++++++++++++++++++ .../protocol1_9to1_8/Protocol1_9To1_8.java | 4 +- .../ServerboundPackets1_9.java} | 4 +- .../Protocol1_9To1_9_1.java | 16 ++-- 32 files changed, 345 insertions(+), 355 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/api/protocol/SimpleProtocol.java rename common/src/main/java/us/myles/ViaVersion/protocols/{protocol1_11to1_10/ClientboundPackets1_11.java => protocol1_9_3to1_9_1_2/ClientboundPackets1_9_3.java} (91%) create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ServerboundPackets1_9_3.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ClientboundPackets1_9.java rename common/src/main/java/us/myles/ViaVersion/protocols/{protocol1_11to1_10/ServerboundPackets1_11.java => protocol1_9to1_8/ServerboundPackets1_9.java} (87%) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java index 8215bf9fe..54318daa7 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java @@ -16,14 +16,24 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; -public abstract class Protocol { +/** + * Abstract protocol class handling packet transformation between two protocol versions. + * Clientbound and serverbount packet types can be set to enforce correct usage of them. + * + * @param old clientbound packet types + * @param new clientbound packet types + * @param old serverbound packet types + * @param new serverbound packet types + * @see SimpleProtocol for a helper class if you do not want to define any of the types above + */ +public abstract class Protocol { private final Map incoming = new HashMap<>(); private final Map outgoing = new HashMap<>(); private final Map storedObjects = new HashMap<>(); // currently only used for MetadataRewriters - protected final Class oldClientboundPacketEnum; - protected final Class newClientboundPacketEnum; - protected final Class oldServerboundPacketEnum; - protected final Class newServerboundPacketEnum; + protected final Class oldClientboundPacketEnum; + protected final Class newClientboundPacketEnum; + protected final Class oldServerboundPacketEnum; + protected final Class newServerboundPacketEnum; protected final boolean hasMappingDataToLoad; protected Protocol() { @@ -37,8 +47,8 @@ public abstract class Protocol { /** * Creates a protocol with automated id mapping if the respective enums are not null. */ - protected Protocol(Class oldClientboundPacketEnum, Class clientboundPacketEnum, - Class oldServerboundPacketEnum, Class serverboundPacketEnum) { + protected Protocol(Class oldClientboundPacketEnum, Class clientboundPacketEnum, + Class oldServerboundPacketEnum, Class serverboundPacketEnum) { this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false); } @@ -47,8 +57,8 @@ public abstract class Protocol { * * @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method */ - protected Protocol(Class oldClientboundPacketEnum, Class clientboundPacketEnum, - Class oldServerboundPacketEnum, Class serverboundPacketEnum, boolean hasMappingDataToLoad) { + protected Protocol(Class oldClientboundPacketEnum, Class clientboundPacketEnum, + Class oldServerboundPacketEnum, Class serverboundPacketEnum, boolean hasMappingDataToLoad) { this.oldClientboundPacketEnum = oldClientboundPacketEnum; this.newClientboundPacketEnum = clientboundPacketEnum; this.oldServerboundPacketEnum = oldServerboundPacketEnum; @@ -139,9 +149,10 @@ public abstract class Protocol { } /** - * Register the packets for this protocol. + * Register the packets for this protocol. To be overriden. */ - protected abstract void registerPackets(); + protected void registerPackets() { + } /** * Load mapping data for the protocol. @@ -254,7 +265,6 @@ public abstract class Protocol { cancelOutgoing(state, oldPacketID, -1); } - public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) { ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper); Packet packet = new Packet(state, oldPacketID); @@ -265,15 +275,14 @@ public abstract class Protocol { outgoing.put(packet, protocolPacket); } + /** * Registers an outgoing protocol and automatically maps it to the new id. * - * @param packetType packet type the server sends + * @param packetType clientbound packet type the server sends * @param packetRemapper remapper */ - public void registerOutgoing(ClientboundPacketType packetType, PacketRemapper packetRemapper) { - Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum); - + public void registerOutgoing(C1 packetType, PacketRemapper packetRemapper) { ClientboundPacketType mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? packetType : Arrays.stream(newClientboundPacketEnum.getEnumConstants()).filter(en -> en.name().equals(packetType.name())).findAny().orElse(null); Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!"); @@ -286,32 +295,36 @@ public abstract class Protocol { /** * Registers an outgoing protocol. * - * @param packetType packet type the server initially sends - * @param mappedPacketType packet type after transforming for the client + * @param packetType clientbound packet type the server initially sends + * @param mappedPacketType clientbound packet type after transforming for the client * @param packetRemapper remapper */ - public void registerOutgoing(ClientboundPacketType packetType, ClientboundPacketType mappedPacketType, PacketRemapper packetRemapper) { - Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum); - Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == newClientboundPacketEnum); + public void registerOutgoing(C1 packetType, C2 mappedPacketType, PacketRemapper packetRemapper) { registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper); } - public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType) { - registerOutgoing(oldPacketType, newPacketType, null); + /** + * Maps a packet type to another packet type without a packet handler. + * Note that this should not be called for simple channel mappings of the same packet; this is already done automatically. + * + * @param packetType clientbound packet type the server initially sends + * @param mappedPacketType clientbound packet type after transforming for the client + */ + public void registerOutgoing(C1 packetType, C2 mappedPacketType) { + registerOutgoing(packetType, mappedPacketType, null); } - public void cancelOutgoing(ClientboundPacketType packetType) { - Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum); + public void cancelOutgoing(C1 packetType) { cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal()); } /** * Registers an incoming protocol and automatically maps it to the server's id. * - * @param packetType packet type the client sends + * @param packetType serverbound packet type the client sends * @param packetRemapper remapper */ - public void registerIncoming(ServerboundPacketType packetType, PacketRemapper packetRemapper) { + public void registerIncoming(S2 packetType, PacketRemapper packetRemapper) { Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum); ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType @@ -326,17 +339,15 @@ public abstract class Protocol { /** * Registers an incoming protocol. * - * @param packetType packet type initially sent by the client - * @param mappedPacketType packet type after transforming for the server + * @param packetType serverbound packet type initially sent by the client + * @param mappedPacketType serverbound packet type after transforming for the server * @param packetRemapper remapper */ - public void registerIncoming(ServerboundPacketType packetType, ServerboundPacketType mappedPacketType, PacketRemapper packetRemapper) { - Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum); - Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == oldServerboundPacketEnum); + public void registerIncoming(S2 packetType, S1 mappedPacketType, PacketRemapper packetRemapper) { registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper); } - public void cancelIncoming(ServerboundPacketType packetType) { + public void cancelIncoming(S2 packetType) { Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum); cancelIncoming(State.PLAY, -1, packetType.ordinal()); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/SimpleProtocol.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/SimpleProtocol.java new file mode 100644 index 000000000..efd0f060f --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/SimpleProtocol.java @@ -0,0 +1,24 @@ +package us.myles.ViaVersion.api.protocol; + +/** + * Dummy protocol class for when you do not need any of the existing packet type enums + * or automated channel mappings. + * + * @see Protocol + */ +public abstract class SimpleProtocol extends Protocol { + + protected SimpleProtocol() { + } + + protected SimpleProtocol(boolean hasMappingDataToLoad) { + super(hasMappingDataToLoad); + } + + public enum DummyPacketTypes implements ClientboundPacketType, ServerboundPacketType { + } + + @Override + protected void registerPackets() { + } +} 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 4cc3eb31a..4495feca8 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 @@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.protocol.ServerboundPacketType; 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 { @@ -117,77 +116,6 @@ public class ItemRewriter { return wrapper -> toServer.rewrite(wrapper.get(type, 0)); } - @Deprecated - 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)); - } - }); - } - - @Deprecated - 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)); - } - }); - } - - @Deprecated - 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)); - } - }); - } - - @Deprecated - 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)); - } - }); - } - - @Deprecated - 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)); - } - }); - } - @FunctionalInterface public interface RewriteFunction { 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 de6a769af..f11a6323f 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 @@ -10,7 +10,6 @@ import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.storage.EntityTracker; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import java.util.ArrayList; @@ -205,78 +204,6 @@ public abstract class MetadataRewriter { return getTrackerAndRewriter(null); } - @Deprecated - public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) { - protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension - handler(wrapper -> { - ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); - clientChunks.setEnvironment(dimensionId); - - if (playerType != null) { - wrapper.user().get(entityTrackerClass).addEntity(wrapper.get(Type.INT, 0), playerType); - } - }); - } - }); - } - - @Deprecated - public void registerRespawn(int oldPacketId, int newPacketId) { - protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); - handler(wrapper -> { - ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); - clientWorld.setEnvironment(dimensionId); - }); - } - }); - } - - @Deprecated - public void registerEntityDestroy(int oldPacketId, int newPacketId) { - protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids - handler(wrapper -> { - EntityTracker entityTracker = wrapper.user().get(entityTrackerClass); - for (int entity : wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0)) { - entityTracker.removeEntity(entity); - } - }); - } - }); - } - - @Deprecated - public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type> oldMetaType, Type> newMetaType) { - protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - if (oldMetaType != null) { - map(oldMetaType, newMetaType); - } else { - map(newMetaType); - } - handler(wrapper -> { - int entityId = wrapper.get(Type.VAR_INT, 0); - List metadata = wrapper.get(newMetaType, 0); - handleMetadata(entityId, metadata, wrapper.user()); - }); - } - }); - } - // --------------------------------------------------------------------------- // Sub 1.14.1 methods diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java index 7d05cadc6..2646513d4 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java @@ -8,28 +8,24 @@ import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.api.type.types.version.Metadata1_9Type; -import us.myles.ViaVersion.api.type.types.version.MetadataList1_9Type; import us.myles.ViaVersion.api.type.types.version.Types1_9; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -public class Protocol1_10To1_9_3_4 extends Protocol { - @Deprecated - public static final Type> METADATA_LIST = new MetadataList1_9Type(); - @Deprecated - public static final Type METADATA = new Metadata1_9Type(); +public class Protocol1_10To1_9_3_4 extends Protocol { - public static final ValueTransformer toNewPitch = new ValueTransformer(Type.FLOAT) { + public static final ValueTransformer TO_NEW_PITCH = new ValueTransformer(Type.FLOAT) { @Override public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception { return inputValue / 63.5F; } }; - public static final ValueTransformer, List> transformMetadata = new ValueTransformer, List>(Types1_9.METADATA_LIST) { + public static final ValueTransformer, List> TRANSFORM_METADATA = new ValueTransformer, List>(Types1_9.METADATA_LIST) { @Override public List transform(PacketWrapper wrapper, List inputValue) throws Exception { List metaList = new CopyOnWriteArrayList<>(inputValue); @@ -41,6 +37,10 @@ public class Protocol1_10To1_9_3_4 extends Protocol { } }; + public Protocol1_10To1_9_3_4() { + super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class); + } + @Override protected void registerPackets() { // Named sound effect @@ -53,7 +53,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol { map(Type.INT); // 3 - y map(Type.INT); // 4 - z map(Type.FLOAT); // 5 - Volume - map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch + map(Type.UNSIGNED_BYTE, TO_NEW_PITCH); // 6 - Pitch } }); @@ -67,7 +67,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol { map(Type.INT); // 3 - y map(Type.INT); // 4 - z map(Type.FLOAT); // 5 - Volume - map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch + map(Type.UNSIGNED_BYTE, TO_NEW_PITCH); // 6 - Pitch handler(new PacketHandler() { @Override @@ -84,7 +84,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity ID - map(Types1_9.METADATA_LIST, transformMetadata); // 1 - Metadata list + map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 1 - Metadata list } }); @@ -104,7 +104,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol { map(Type.SHORT); // 9 - Velocity X map(Type.SHORT); // 10 - Velocity Y map(Type.SHORT); // 11 - Velocity Z - map(Types1_9.METADATA_LIST, transformMetadata); // 12 - Metadata + map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 12 - Metadata } }); @@ -119,7 +119,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol { map(Type.DOUBLE); // 4 - Z map(Type.BYTE); // 5 - Yaw map(Type.BYTE); // 6 - Pitch - map(Types1_9.METADATA_LIST, transformMetadata); // 7 - Metadata list + map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 7 - Metadata list } }); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11_1to1_11/Protocol1_11_1To1_11.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11_1to1_11/Protocol1_11_1To1_11.java index a829ff404..9d16e420f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11_1to1_11/Protocol1_11_1To1_11.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11_1to1_11/Protocol1_11_1To1_11.java @@ -1,11 +1,8 @@ package us.myles.ViaVersion.protocols.protocol1_11_1to1_11; import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -public class Protocol1_11_1To1_11 extends Protocol { - - @Override - protected void registerPackets() { - // Only had metadata changes, see wiki.vg for full info. - } +public class Protocol1_11_1To1_11 extends Protocol { } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java index 225482462..6dd4c4eb4 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java @@ -15,14 +15,15 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.types.version.Types1_9; -import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10; import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11; 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; -public class Protocol1_11To1_10 extends Protocol { +public class Protocol1_11To1_10 extends Protocol { private static final ValueTransformer toOldByte = new ValueTransformer(Type.UNSIGNED_BYTE) { @Override public Short transform(PacketWrapper wrapper, Float inputValue) throws Exception { @@ -30,14 +31,17 @@ public class Protocol1_11To1_10 extends Protocol { } }; + public Protocol1_11To1_10() { + super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class); + } + @Override protected void registerPackets() { MetadataRewriter1_11To1_10 metadataRewriter = new MetadataRewriter1_11To1_10(this); InventoryPackets.register(this); - // Spawn Object - registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity id @@ -49,8 +53,7 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Spawn mob packet - registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity ID @@ -87,10 +90,9 @@ public class Protocol1_11To1_10 extends Protocol { } }); - //new SoundRewriter(this, this::getNewSoundId).registerSound(0x46, 0x46); //TODO _------------------------------------------------------ + new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND); - // Collect item packet - registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Collected entity id @@ -105,11 +107,9 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Metadata packet - metadataRewriter.registerMetadataRewriter(0x39, 0x39, null, Types1_9.METADATA_LIST); + metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST); - // Entity teleport - registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.ENTITY_TELEPORT, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity id @@ -137,11 +137,9 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Destroy entities - metadataRewriter.registerEntityDestroy(0x30, 0x30); + metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES); - // Title packet - registerOutgoing(State.PLAY, 0x45, 0x45, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.TITLE, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Action @@ -161,8 +159,7 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Block action packet - registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.BLOCK_ACTION, new PacketRemapper() { @Override public void registerMap() { map(Type.POSITION); // 0 - Position @@ -185,8 +182,7 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Update Block Entity - registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() { @Override public void registerMap() { map(Type.POSITION); // 0 - Position @@ -209,8 +205,7 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Chunk Data - registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { @@ -240,18 +235,15 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Join (save dimension id) - metadataRewriter.registerJoinGame(0x23, 0x23, null); + metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null); - // Respawn (save dimension id) - metadataRewriter.registerRespawn(0x33, 0x33); + metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN); /* INCOMING PACKETS - */ + */ - // Block placement - registerIncoming(State.PLAY, 0x1C, 0x1C, new PacketRemapper() { + registerIncoming(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() { @Override public void registerMap() { map(Type.POSITION); // 0 - Location @@ -264,8 +256,7 @@ public class Protocol1_11To1_10 extends Protocol { } }); - // Chat Message Incoming - registerIncoming(State.PLAY, 0x02, 0x02, new PacketRemapper() { + registerIncoming(ServerboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() { @Override public void registerMap() { map(Type.STRING); // 0 - Message 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 4c731116f..fa87fc5db 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 @@ -5,7 +5,8 @@ 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_9_3to1_9_1_2.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter; import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10; @@ -14,17 +15,12 @@ public class InventoryPackets { public static void register(Protocol1_11To1_10 protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, EntityIdRewriter::toClientItem, EntityIdRewriter::toServerItem); - // Set slot packet - itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16); - - // Window items packet - itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14); - - // Entity Equipment Packet - itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C); + itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM); + itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY); + itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM); // Plugin message Packet -> Trading - protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() { + protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() { @Override public void registerMap() { map(Type.STRING); // 0 - Channel @@ -54,11 +50,7 @@ public class InventoryPackets { } }); - - // Click window packet - itemRewriter.registerClickWindow(Type.ITEM, 0x07, 0x07); - - // Creative Inventory Action - itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18); + itemRewriter.registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM); + itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12_1to1_12/Protocol1_12_1To1_12.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12_1to1_12/Protocol1_12_1To1_12.java index 4212c41fe..09c4d67f5 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12_1to1_12/Protocol1_12_1To1_12.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12_1to1_12/Protocol1_12_1To1_12.java @@ -4,7 +4,7 @@ import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; -public class Protocol1_12_1To1_12 extends Protocol { +public class Protocol1_12_1To1_12 extends Protocol { public Protocol1_12_1To1_12() { super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java index c8ad8f0f1..2a3eec570 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java @@ -16,8 +16,8 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.types.version.Types1_12; -import us.myles.ViaVersion.protocols.protocol1_11to1_10.ClientboundPackets1_11; -import us.myles.ViaVersion.protocols.protocol1_11to1_10.ServerboundPackets1_11; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.metadata.MetadataRewriter1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider; @@ -27,10 +27,10 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import us.myles.ViaVersion.util.GsonUtil; -public class Protocol1_12To1_11_1 extends Protocol { +public class Protocol1_12To1_11_1 extends Protocol { public Protocol1_12To1_11_1() { - super(ClientboundPackets1_11.class, ClientboundPackets1_12.class, ServerboundPackets1_11.class, ServerboundPackets1_12.class); + super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class); } @Override @@ -39,7 +39,7 @@ public class Protocol1_12To1_11_1 extends Protocol { InventoryPackets.register(this); - registerOutgoing(ClientboundPackets1_11.SPAWN_ENTITY, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity id @@ -51,7 +51,7 @@ public class Protocol1_12To1_11_1 extends Protocol { } }); - registerOutgoing(ClientboundPackets1_11.SPAWN_MOB, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Entity ID @@ -73,7 +73,7 @@ public class Protocol1_12To1_11_1 extends Protocol { } }); - registerOutgoing(ClientboundPackets1_11.CHAT_MESSAGE, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() { @Override public void registerMap() { map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json) @@ -99,7 +99,7 @@ public class Protocol1_12To1_11_1 extends Protocol { } }); - registerOutgoing(ClientboundPackets1_11.CHUNK_DATA, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { @@ -142,12 +142,12 @@ public class Protocol1_12To1_11_1 extends Protocol { } }); - metadataRewriter.registerJoinGame(ClientboundPackets1_11.JOIN_GAME, null); - metadataRewriter.registerEntityDestroy(ClientboundPackets1_11.DESTROY_ENTITIES); - metadataRewriter.registerRespawn(ClientboundPackets1_11.RESPAWN); - metadataRewriter.registerMetadataRewriter(ClientboundPackets1_11.ENTITY_METADATA, Types1_12.METADATA_LIST); + metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null); + metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES); + metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN); + metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST); - new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_11.SOUND); + new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND); // New packet at 0x01 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 d26558df9..a18c36980 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 @@ -7,7 +7,7 @@ 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.protocols.protocol1_11to1_10.ClientboundPackets1_11; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; @@ -18,12 +18,12 @@ public class InventoryPackets { public static void register(Protocol1_12To1_11_1 protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, BedRewriter::toClientItem, BedRewriter::toServerItem); - itemRewriter.registerSetSlot(ClientboundPackets1_11.SET_SLOT, Type.ITEM); - itemRewriter.registerWindowItems(ClientboundPackets1_11.WINDOW_ITEMS, Type.ITEM_ARRAY); - itemRewriter.registerEntityEquipment(ClientboundPackets1_11.ENTITY_EQUIPMENT, Type.ITEM); + itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM); + itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY); + itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM); // Plugin message Packet -> Trading - protocol.registerOutgoing(ClientboundPackets1_11.PLUGIN_MESSAGE, new PacketRemapper() { + protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() { @Override public void registerMap() { map(Type.STRING); // 0 - Channel 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 6d9293afa..06787674b 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 @@ -17,7 +17,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13 import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -public class Protocol1_13_1To1_13 extends Protocol { +public class Protocol1_13_1To1_13 extends Protocol { public Protocol1_13_1To1_13() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java index cc80bf264..e897165d6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java @@ -12,7 +12,7 @@ import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; -public class Protocol1_13_2To1_13_1 extends Protocol { +public class Protocol1_13_2To1_13_1 extends Protocol { public Protocol1_13_2To1_13_1() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 22ec12e69..feb9cef5f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -43,7 +43,7 @@ import us.myles.ViaVersion.util.GsonUtil; import java.util.EnumMap; import java.util.Map; -public class Protocol1_13To1_12_2 extends Protocol { +public class Protocol1_13To1_12_2 extends Protocol { public Protocol1_13To1_12_2() { super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java index b93bdebd7..1007b427d 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_1to1_14/Protocol1_14_1To1_14.java @@ -8,7 +8,7 @@ import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1 import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; -public class Protocol1_14_1To1_14 extends Protocol { +public class Protocol1_14_1To1_14 extends Protocol { public Protocol1_14_1To1_14() { super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_2to1_14_1/Protocol1_14_2To1_14_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_2to1_14_1/Protocol1_14_2To1_14_1.java index 81ff7fbf5..277dfcd8b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_2to1_14_1/Protocol1_14_2To1_14_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_2to1_14_1/Protocol1_14_2To1_14_1.java @@ -1,10 +1,8 @@ package us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1; import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; -public class Protocol1_14_2To1_14_1 extends Protocol { - - @Override - protected void registerPackets() { - } +public class Protocol1_14_2To1_14_1 extends Protocol { } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java index 16fb87047..18dcb1f06 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_3to1_14_2/Protocol1_14_3To1_14_2.java @@ -5,14 +5,18 @@ 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; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; -public class Protocol1_14_3To1_14_2 extends Protocol { +public class Protocol1_14_3To1_14_2 extends Protocol { + + public Protocol1_14_3To1_14_2() { + super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null); + } @Override protected void registerPackets() { - // Trade list - registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_4to1_14_3/Protocol1_14_4To1_14_3.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_4to1_14_3/Protocol1_14_4To1_14_3.java index 9b8eda613..911e89b75 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_4to1_14_3/Protocol1_14_4To1_14_3.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14_4to1_14_3/Protocol1_14_4To1_14_3.java @@ -5,14 +5,18 @@ 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; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; -public class Protocol1_14_4To1_14_3 extends Protocol { +public class Protocol1_14_4To1_14_3 extends Protocol { + + public Protocol1_14_4To1_14_3() { + super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null); + } @Override protected void registerPackets() { - // trade list - registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java index ff5038acb..f668965c0 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java @@ -19,7 +19,7 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -public class Protocol1_14To1_13_2 extends Protocol { +public class Protocol1_14To1_13_2 extends Protocol { public Protocol1_14To1_13_2() { super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_1to1_15/Protocol1_15_1To1_15.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_1to1_15/Protocol1_15_1To1_15.java index f5773ba77..93acae479 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_1to1_15/Protocol1_15_1To1_15.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_1to1_15/Protocol1_15_1To1_15.java @@ -1,10 +1,8 @@ package us.myles.ViaVersion.protocols.protocol1_15_1to1_15; import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; -public class Protocol1_15_1To1_15 extends Protocol { - - @Override - protected void registerPackets() { - } +public class Protocol1_15_1To1_15 extends Protocol { } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_2to1_15_1/Protocol1_15_2To1_15_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_2to1_15_1/Protocol1_15_2To1_15_1.java index 370817009..e140f3b1e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_2to1_15_1/Protocol1_15_2To1_15_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15_2to1_15_1/Protocol1_15_2To1_15_1.java @@ -1,10 +1,8 @@ package us.myles.ViaVersion.protocols.protocol1_15_2to1_15_1; import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; +import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; -public class Protocol1_15_2To1_15_1 extends Protocol { - - @Override - protected void registerPackets() { - } +public class Protocol1_15_2To1_15_1 extends Protocol { } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java index 3fea41554..85c043817 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java @@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -public class Protocol1_15To1_14_4 extends Protocol { +public class Protocol1_15To1_14_4 extends Protocol { private TagRewriter tagRewriter; 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 7da74c857..47f423259 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 @@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import java.util.UUID; -public class Protocol1_16To1_15_2 extends Protocol { +public class Protocol1_16To1_15_2 extends Protocol { public static final UUID ZERO_UUID = new UUID(0, 0); private TagRewriter tagRewriter; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java index 12821a29b..1b3ebcbb3 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1_2to1_9_3_4/Protocol1_9_1_2To1_9_3_4.java @@ -9,27 +9,25 @@ 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; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity; 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.ClientboundPackets1_9_3; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -public class Protocol1_9_1_2To1_9_3_4 extends Protocol { +// Goes BACKWARDS from 1.9.3/4 to 1.9.1/2 +public class Protocol1_9_1_2To1_9_3_4 extends Protocol { + + public Protocol1_9_1_2To1_9_3_4() { + super(ClientboundPackets1_9_3.class, ClientboundPackets1_9.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9.class); + } @Override protected void registerPackets() { - - //Unchanged packet structure - registerOutgoing(State.PLAY, 0x46, 0x47); //Sound effect - registerOutgoing(State.PLAY, 0x47, 0x48); //Player list header and footer - registerOutgoing(State.PLAY, 0x48, 0x49); //Collect item - registerOutgoing(State.PLAY, 0x49, 0x4A); //Entity teleport - registerOutgoing(State.PLAY, 0x4A, 0x4B); //Entity properties - registerOutgoing(State.PLAY, 0x4B, 0x4C); //Entity effect - - //Update block entity - registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() { @Override public void registerMap() { map(Type.POSITION); //Position @@ -54,8 +52,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol { } }); - // Chunk Packet - registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { @@ -74,8 +71,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol { } }); - // Join (save dimension id) - registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Entity ID @@ -94,8 +90,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol { } }); - // Respawn (save dimension id) - registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Dimension ID @@ -115,7 +110,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol { @Override public void init(UserConnection userConnection) { - if (!userConnection.has(ClientWorld.class)) + if (!userConnection.has(ClientWorld.class)) { userConnection.put(new ClientWorld(userConnection)); + } } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1to1_9/Protocol1_9_1To1_9.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1to1_9/Protocol1_9_1To1_9.java index b1e0e1877..45be14ce7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1to1_9/Protocol1_9_1To1_9.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_1to1_9/Protocol1_9_1To1_9.java @@ -5,15 +5,20 @@ 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; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -public class Protocol1_9_1To1_9 extends Protocol { +public class Protocol1_9_1To1_9 extends Protocol { + + public Protocol1_9_1To1_9() { + super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class); + } @Override protected void registerPackets() { // Currently supports 1.9.1 and 1.9.2 - // Join Game Packet - registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { + + registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Player ID @@ -27,8 +32,7 @@ public class Protocol1_9_1To1_9 extends Protocol { } }); - // Sound Effect Packet - registerOutgoing(State.PLAY, 0x47, 0x47, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.SOUND, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Sound ID diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ClientboundPackets1_11.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ClientboundPackets1_9_3.java similarity index 91% rename from common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ClientboundPackets1_11.java rename to common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ClientboundPackets1_9_3.java index 051d787dc..77558b97f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ClientboundPackets1_11.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ClientboundPackets1_9_3.java @@ -1,8 +1,8 @@ -package us.myles.ViaVersion.protocols.protocol1_11to1_10; +package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2; import us.myles.ViaVersion.api.protocol.ClientboundPacketType; -public enum ClientboundPackets1_11 implements ClientboundPacketType { +public enum ClientboundPackets1_9_3 implements ClientboundPacketType { SPAWN_ENTITY, // 0x00 SPAWN_EXPERIENCE_ORB, // 0x01 @@ -78,6 +78,6 @@ public enum ClientboundPackets1_11 implements ClientboundPacketType { TAB_LIST, // 0x49 COLLECT_ITEM, // 0x4A ENTITY_TELEPORT, // 0x4B - ENTITY_PROPERTIES, // 0x4D - ENTITY_EFFECT, // 0x4E + ENTITY_PROPERTIES, // 0x4C + ENTITY_EFFECT, // 0x4D } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java index 8ded27823..58b82a7af 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java @@ -12,31 +12,26 @@ 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; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntity; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9; import java.util.List; -public class Protocol1_9_3To1_9_1_2 extends Protocol { +public class Protocol1_9_3To1_9_1_2 extends Protocol { + + public Protocol1_9_3To1_9_1_2() { + super(ClientboundPackets1_9.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9.class, ServerboundPackets1_9_3.class); + } @Override protected void registerPackets() { - - //Unchanged packet structure - registerOutgoing(State.PLAY, 0x47, 0x46); //Sound effect - registerOutgoing(State.PLAY, 0x48, 0x47); //Player list header and footer - registerOutgoing(State.PLAY, 0x49, 0x48); //Collect item - registerOutgoing(State.PLAY, 0x4A, 0x49); //Entity teleport - registerOutgoing(State.PLAY, 0x4B, 0x4A); //Entity properties - registerOutgoing(State.PLAY, 0x4C, 0x4B); //Entity effect - // Sign update packet - registerOutgoing(State.PLAY, 0x46, -1, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.UPDATE_SIGN, null, new PacketRemapper() { @Override public void registerMap() { - handler(new PacketHandler() { @Override public void handle(PacketWrapper wrapper) throws Exception { @@ -68,8 +63,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol { } }); - // Chunk packet - registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() { handler(new PacketHandler() { @@ -105,8 +99,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol { } }); - // Join (save dimension id) - registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Entity ID @@ -124,8 +117,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol { } }); - // Respawn (save dimension id) - registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.RESPAWN, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Dimension ID @@ -143,7 +135,8 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol { @Override public void init(UserConnection user) { - if (!user.has(ClientWorld.class)) + if (!user.has(ClientWorld.class)) { user.put(new ClientWorld(user)); + } } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ServerboundPackets1_9_3.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ServerboundPackets1_9_3.java new file mode 100644 index 000000000..f20e4f55e --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9_3to1_9_1_2/ServerboundPackets1_9_3.java @@ -0,0 +1,37 @@ +package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2; + +import us.myles.ViaVersion.api.protocol.ServerboundPacketType; + +public enum ServerboundPackets1_9_3 implements ServerboundPacketType { + + TELEPORT_CONFIRM, // 0x00 + TAB_COMPLETE, // 0x01 + CHAT_MESSAGE, // 0x02 + CLIENT_STATUS, // 0x03 + CLIENT_SETTINGS, // 0x04 + WINDOW_CONFIRMATION, // 0x05 + CLICK_WINDOW_BUTTON, // 0x06 + CLICK_WINDOW, // 0x07 + CLOSE_WINDOW, // 0x08 + PLUGIN_MESSAGE, // 0x09 + INTERACT_ENTITY, // 0x0A + KEEP_ALIVE, // 0x0B + PLAYER_POSITION, // 0x0C + PLAYER_POSITION_AND_ROTATION, // 0x0D + PLAYER_ROTATION, // 0x0E + PLAYER_MOVEMENT, // 0x0F + VEHICLE_MOVE, // 0x10 + STEER_BOAT, // 0x11 + PLAYER_ABILITIES, // 0x12 + PLAYER_DIGGING, // 0x13 + ENTITY_ACTION, // 0x14 + STEER_VEHICLE, // 0x15 + RESOURCE_PACK_STATUS, // 0x16 + HELD_ITEM_CHANGE, // 0x17 + CREATIVE_INVENTORY_ACTION, // 0x18 + UPDATE_SIGN, // 0x19 + ANIMATION, // 0x1A + SPECTATE, // 0x1B + PLAYER_BLOCK_PLACEMENT, // 0x1C + USE_ITEM, // 0x1D +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ClientboundPackets1_9.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ClientboundPackets1_9.java new file mode 100644 index 000000000..d89372dea --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ClientboundPackets1_9.java @@ -0,0 +1,84 @@ +package us.myles.ViaVersion.protocols.protocol1_9to1_8; + +import us.myles.ViaVersion.api.protocol.ClientboundPacketType; + +public enum ClientboundPackets1_9 implements ClientboundPacketType { + + SPAWN_ENTITY, // 0x00 + SPAWN_EXPERIENCE_ORB, // 0x01 + SPAWN_GLOBAL_ENTITY, // 0x02 + SPAWN_MOB, // 0x03 + SPAWN_PAINTING, // 0x04 + SPAWN_PLAYER, // 0x05 + ENTITY_ANIMATION, // 0x06 + STATISTICS, // 0x07 + BLOCK_BREAK_ANIMATION, // 0x08 + BLOCK_ENTITY_DATA, // 0x09 + BLOCK_ACTION, // 0x0A + BLOCK_CHANGE, // 0x0B + BOSSBAR, // 0x0C + SERVER_DIFFICULTY, // 0x0D + TAB_COMPLETE, // 0x0E + CHAT_MESSAGE, // 0x0F + MULTI_BLOCK_CHANGE, // 0x10 + WINDOW_CONFIRMATION, // 0x11 + CLOSE_WINDOW, // 0x12 + OPEN_WINDOW, // 0x13 + WINDOW_ITEMS, // 0x14 + WINDOW_PROPERTY, // 0x15 + SET_SLOT, // 0x16 + COOLDOWN, // 0x17 + PLUGIN_MESSAGE, // 0x18 + NAMED_SOUND, // 0x19 + DISCONNECT, // 0x1A + ENTITY_STATUS, // 0x1B + EXPLOSION, // 0x1C + UNLOAD_CHUNK, // 0x1D + GAME_EVENT, // 0x1E + KEEP_ALIVE, // 0x1F + CHUNK_DATA, // 0x20 + EFFECT, // 0x21 + SPAWN_PARTICLE, // 0x22 + JOIN_GAME, // 0x23 + MAP_DATA, // 0x24 + ENTITY_POSITION, // 0x26 + ENTITY_POSITION_AND_ROTATION, // 0x27 + ENTITY_ROTATION, // 0x28 + ENTITY_MOVEMENT, // 0x25 + VEHICLE_MOVE, // 0x29 + OPEN_SIGN_EDITOR, // 0x2A + PLAYER_ABILITIES, // 0x2B + COMBAT_EVENT, // 0x2C + PLAYER_INFO, // 0x2D + PLAYER_POSITION, // 0x2E + USE_BED, // 0x2F + DESTROY_ENTITIES, // 0x31 + REMOVE_ENTITY_EFFECT, // 0x32 + RESOURCE_PACK, // 0x33 + RESPAWN, // 0x34 + ENTITY_HEAD_LOOK, // 0x35 + WORLD_BORDER, // 0x37 + CAMERA, // 0x38 + HELD_ITEM_CHANGE, // 0x39 + DISPLAY_SCOREBOARD, // 0x3A + ENTITY_METADATA, // 0x3B + ATTACH_ENTITY, // 0x3C + ENTITY_VELOCITY, // 0x3D + ENTITY_EQUIPMENT, // 0x3E + SET_EXPERIENCE, // 0x3F + UPDATE_HEALTH, // 0x40 + SCOREBOARD_OBJECTIVE, // 0x41 + SET_PASSENGERS, // 0x42 + TEAMS, // 0x43 + UPDATE_SCORE, // 0x44 + SPAWN_POSITION, // 0x45 + TIME_UPDATE, // 0x46 + TITLE, // 0x47 + UPDATE_SIGN, // 0x48 + SOUND, // 0x49 + TAB_LIST, // 0x4A + COLLECT_ITEM, // 0x4B + ENTITY_TELEPORT, // 0x4C + ENTITY_PROPERTIES, // 0x4D + ENTITY_EFFECT, // 0x4E +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java index 0861ee7c1..c372f88a6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9To1_8.java @@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.platform.providers.ViaProviders; -import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.protocol.SimpleProtocol; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; @@ -19,7 +19,7 @@ import us.myles.ViaVersion.util.GsonUtil; import java.util.List; -public class Protocol1_9To1_8 extends Protocol { +public class Protocol1_9To1_8 extends SimpleProtocol { public static final ValueTransformer FIX_JSON = new ValueTransformer(Type.STRING) { @Override public String transform(PacketWrapper wrapper, String line) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ServerboundPackets1_11.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ServerboundPackets1_9.java similarity index 87% rename from common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ServerboundPackets1_11.java rename to common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ServerboundPackets1_9.java index 5b3330ff6..fd2ae5781 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/ServerboundPackets1_11.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ServerboundPackets1_9.java @@ -1,8 +1,8 @@ -package us.myles.ViaVersion.protocols.protocol1_11to1_10; +package us.myles.ViaVersion.protocols.protocol1_9to1_8; import us.myles.ViaVersion.api.protocol.ServerboundPacketType; -public enum ServerboundPackets1_11 implements ServerboundPacketType { +public enum ServerboundPackets1_9 implements ServerboundPacketType { TELEPORT_CONFIRM, // 0x00 TAB_COMPLETE, // 0x01 diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java index 5b00f1f52..dab2a898b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_9_1/Protocol1_9To1_9_1.java @@ -5,15 +5,20 @@ 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; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -public class Protocol1_9To1_9_1 extends Protocol { +public class Protocol1_9To1_9_1 extends Protocol { + + public Protocol1_9To1_9_1() { + super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class); + } @Override protected void registerPackets() { // Currently supports 1.9.1 and 1.9.2 - // Join Game Packet - registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { + + registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() { @Override public void registerMap() { map(Type.INT); // 0 - Player ID @@ -27,8 +32,7 @@ public class Protocol1_9To1_9_1 extends Protocol { } }); - // Sound Effect Packet - registerOutgoing(State.PLAY, 0x47, 0x47, new PacketRemapper() { + registerOutgoing(ClientboundPackets1_9.SOUND, new PacketRemapper() { @Override public void registerMap() { map(Type.VAR_INT); // 0 - Sound ID