From 3b533b513884ddef9d8b4946527e7bd886e82158 Mon Sep 17 00:00:00 2001 From: Matsv Date: Thu, 2 Jun 2016 18:37:05 +0200 Subject: [PATCH] Compatibility with 1.10-pre1 (number 2, git didn't push everything for some reason) --- pom.xml | 2 +- .../api/protocol/ProtocolVersion.java | 2 +- .../ProtocolSnapshotTo1_9_3.java | 35 ++++++++++++++++++- .../storage/ResourcePackTracker.java | 4 ++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 8facae405..5460d0465 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ us.myles viaversion - 16w21a-DEV + 1.10-pre1-DEV jar ViaVersion 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 bf4ce094d..95a578113 100644 --- a/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -29,7 +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/4")); - register(SNAPSHOT = new ProtocolVersion(203, "16w21b")); + register(SNAPSHOT = new ProtocolVersion(204, "1.10-pre1")); } 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 index 54ca3d0c1..c10d0365b 100644 --- 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 @@ -9,6 +9,7 @@ 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.packets.State; +import us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.storage.ResourcePackTracker; import java.util.List; @@ -104,6 +105,38 @@ public class ProtocolSnapshotTo1_9_3 extends Protocol { map(METADATA_LIST); // 7 - Metadata list } }); + + // Packet Send ResourcePack + registerOutgoing(State.PLAY, 0x32, 0x32, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.STRING); // 0 - URL + map(Type.STRING); // 1 - Hash + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class); + tracker.setLastHash(wrapper.get(Type.STRING, 1)); // Store the hash for resourcepack status + } + }); + } + }); + + // Packet ResourcePack status + registerIncoming(State.PLAY, 0x16, 0x16, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ResourcePackTracker tracker = wrapper.user().get(ResourcePackTracker.class); + wrapper.write(Type.STRING, tracker.getLastHash()); + wrapper.write(Type.VAR_INT, wrapper.read(Type.VAR_INT)); + } + }); + } + }); } public int getNewSoundId(int id) { //TODO organize things later @@ -116,6 +149,6 @@ public class ProtocolSnapshotTo1_9_3 extends Protocol { @Override public void init(UserConnection userConnection) { - + userConnection.put(new ResourcePackTracker(userConnection)); } } diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/storage/ResourcePackTracker.java b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/storage/ResourcePackTracker.java index 26b6dc2fd..c72e7eae5 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/storage/ResourcePackTracker.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_9_3/storage/ResourcePackTracker.java @@ -1,6 +1,8 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_9_3.storage; -import lombok.*; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.UserConnection;