From 6cfb21f660727854b19c33ae5c638c15b9e6dc78 Mon Sep 17 00:00:00 2001 From: Marco Neuhaus Date: Wed, 8 Aug 2018 18:58:25 +0200 Subject: [PATCH] add support for 18w32a --- .../api/protocol/ProtocolRegistry.java | 4 ++-- .../api/protocol/ProtocolVersion.java | 4 ++-- .../MetadataRewriter.java | 6 +++--- .../Protocol18w32aTO1_13.java} | 19 ++++++++++++------- 4 files changed, 19 insertions(+), 14 deletions(-) rename common/src/main/java/us/myles/ViaVersion/protocols/{protocol18w31ato1_13 => protocol18w32ato1_13}/MetadataRewriter.java (89%) rename common/src/main/java/us/myles/ViaVersion/protocols/{protocol18w31ato1_13/Protocol18w31aTO1_13.java => protocol18w32ato1_13/Protocol18w32aTO1_13.java} (97%) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java index cddf1a730..c6af45153 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolRegistry.java @@ -19,7 +19,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.protocol18w31ato1_13.Protocol18w31aTO1_13; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.Protocol18w32aTO1_13; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -57,7 +57,7 @@ public class ProtocolRegistry { // 1.13 support in development! (: registerProtocol(new Protocol1_13To1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId()); - registerProtocol(new Protocol18w31aTO1_13(), Arrays.asList(ProtocolVersion.v18w31a.getId()), ProtocolVersion.v1_13.getId()); + registerProtocol(new Protocol18w32aTO1_13(), Arrays.asList(ProtocolVersion.v18w32a.getId()), ProtocolVersion.v1_13.getId()); } /** diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 1041961e4..8fb744bab 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -34,7 +34,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_12_2; // v1_13 as name for better ViaBackwards compatibility. public static final ProtocolVersion v1_13; - public static final ProtocolVersion v18w31a; + public static final ProtocolVersion v18w32a; public static final ProtocolVersion unknown; private final int id; @@ -64,7 +64,7 @@ public class ProtocolVersion { register(v1_12_1 = new ProtocolVersion(338, "1.12.1")); register(v1_12_2 = new ProtocolVersion(340, "1.12.2")); register(v1_13 = new ProtocolVersion(393, "1.13")); - register(v18w31a = new ProtocolVersion(396, "18w31a")); + register(v18w32a = new ProtocolVersion(397, "18w32a")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/MetadataRewriter.java similarity index 89% rename from common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/MetadataRewriter.java rename to common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/MetadataRewriter.java index 4289166c3..b2ef64de7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/MetadataRewriter.java @@ -1,4 +1,4 @@ -package us.myles.ViaVersion.protocols.protocol18w31ato1_13; +package us.myles.ViaVersion.protocols.protocol18w32ato1_13; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; @@ -17,13 +17,13 @@ public class MetadataRewriter { if (metadata.getMetaType() == MetaType1_13.BlockID) { // Convert to new block id int data = (int) metadata.getValue(); - metadata.setValue(Protocol18w31aTO1_13.getMapBlockId(data)); + metadata.setValue(Protocol18w32aTO1_13.getMapBlockId(data)); } if(type == null) continue; if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) { // New block format int data = (int) metadata.getValue(); - metadata.setValue(Protocol18w31aTO1_13.getMapBlockId(data)); + metadata.setValue(Protocol18w32aTO1_13.getMapBlockId(data)); } } catch (Exception e) { metadatas.remove(metadata); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/Protocol18w31aTO1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java similarity index 97% rename from common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/Protocol18w31aTO1_13.java rename to common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java index 732df57d8..812ef1bf6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w31ato1_13/Protocol18w31aTO1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java @@ -1,4 +1,4 @@ -package us.myles.ViaVersion.protocols.protocol18w31ato1_13; +package us.myles.ViaVersion.protocols.protocol18w32ato1_13; import com.google.common.base.Optional; import us.myles.ViaVersion.api.PacketWrapper; @@ -18,7 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -public class Protocol18w31aTO1_13 extends Protocol { +public class Protocol18w32aTO1_13 extends Protocol { @Override protected void registerPackets() { @@ -351,12 +351,17 @@ public class Protocol18w31aTO1_13 extends Protocol { } - public static int getMapBlockId(int blockId){ - if(blockId > 8573){ - return blockId +2; - }else if(blockId > 1126){ - return blockId +1; + public static int getMapBlockId(int blockId) { + if (blockId > 8573) { + blockId += 17; + } else if (blockId > 8463) { + blockId += 16; + } else if (blockId > 8458) { + blockId = 8470 + (blockId - 8459) * 2; + } else if (blockId > 1126) { + blockId += 1; } + return blockId; } }