From 2456c3cf17c69dda0341f5b977d7a3ca50a4fdb7 Mon Sep 17 00:00:00 2001 From: Matsv Date: Wed, 18 May 2016 16:43:57 +0200 Subject: [PATCH] Basic support for the new 1.10 snapshot 16w20a --- .../api/protocol/ProtocolRegistry.java | 2 + .../api/protocol/ProtocolVersion.java | 2 + .../ProtocolSnapshotTo1_9_3.java | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index 0c05ea35f..787ec6f69 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -8,6 +8,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_9_1.Protocol1_9TO1_9_1; +import us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.ProtocolSnapshotTo1_9_3; import java.util.*; @@ -29,6 +30,7 @@ public class ProtocolRegistry { // Only supported for 1.9.4 server to 1.9 (nothing else) registerProtocol(new Protocol1_9TO1_9_1(), Arrays.asList(ProtocolVersion.v1_9.getId()), ProtocolVersion.v1_9_2.getId()); registerProtocol(new Protocol1_9_1_2TO1_9_3(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9_3.getId()); + registerProtocol(new ProtocolSnapshotTo1_9_3(), Collections.singletonList(ProtocolVersion.SNAPSHOT.getId()), ProtocolVersion.v1_9_3.getId()); } diff --git a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 04e08aec3..6108629e4 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -16,6 +16,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_9_1; public static final ProtocolVersion v1_9_2; public static final ProtocolVersion v1_9_3; + public static final ProtocolVersion SNAPSHOT; private final int id; private final String name; @@ -28,6 +29,7 @@ public class ProtocolVersion { register(v1_9_1 = new ProtocolVersion(108, "1.9.1")); register(v1_9_2 = new ProtocolVersion(109, "1.9.2")); register(v1_9_3 = new ProtocolVersion(110, "1.9.3")); + register(SNAPSHOT = new ProtocolVersion(201, "16w20a")); } public static void register(@NonNull ProtocolVersion protocol) { diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java new file mode 100644 index 000000000..401a0acf8 --- /dev/null +++ b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/ProtocolSnapshotTo1_9_3.java @@ -0,0 +1,46 @@ +package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.State; + +public class ProtocolSnapshotTo1_9_3 extends Protocol { + @Override + protected void registerPackets() { + // Named sound effect + registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.STRING); // 0 - Sound name + map(Type.VAR_INT); // 1 - Sound Category + map(Type.INT); // 2 - x + map(Type.INT); // 3 - y + map(Type.INT); // 4 - z + map(Type.FLOAT); // 5 - Volume + map(Type.UNSIGNED_BYTE, Type.FLOAT); // 6 - Pitch + } + }); + + // Sound effect + registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Sound name + map(Type.VAR_INT); // 1 - Sound Category + map(Type.INT); // 2 - x + map(Type.INT); // 3 - y + map(Type.INT); // 4 - z + map(Type.FLOAT); // 5 - Volume + map(Type.UNSIGNED_BYTE, Type.FLOAT); // 6 - Pitch + } + }); + + } + + @Override + public void init(UserConnection userConnection) { + + } +}