From e261ced7016696e228e79adfb5b9cbb570d549fa Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 14:04:29 +0100 Subject: [PATCH 1/7] fix teams packet --- .../packets/PlayerPacket1_13.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) 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 7d0ba1da..679a48ee 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 @@ -105,23 +105,32 @@ public class PlayerPacket1_13 extends Rewriter { if (displayName.length() > 32) displayName = displayName.substring(0, 32); wrapper.write(Type.STRING, displayName); - String prefix = wrapper.read(Type.STRING); - String suffix = wrapper.read(Type.STRING); - - wrapper.passthrough(Type.BYTE); //Flags - - wrapper.passthrough(Type.STRING); //Name Tag Visibility - wrapper.passthrough(Type.STRING); //Collision Rule + byte flags = wrapper.read(Type.BYTE); + String nameTagVisibility = wrapper.read(Type.STRING); + String collisionRule = wrapper.read(Type.STRING); int colour = wrapper.read(Type.VAR_INT); if (colour == 21) { colour = -1; } - wrapper.write(Type.BYTE, (byte) colour); + //TODO team color/prefix handling changed from 1.12.2 to 1.13 and to 1.13.1 again afaik + String prefix = wrapper.read(Type.STRING); + String suffix = wrapper.read(Type.STRING); + prefix = ChatRewriter.jsonTextToLegacy(prefix); + prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r"); + if (prefix.length() > 16) prefix = prefix.substring(0, 16); + if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1); + suffix = ChatRewriter.jsonTextToLegacy(suffix); + if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1); + wrapper.write(Type.STRING, prefix); + wrapper.write(Type.STRING, suffix); - wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(prefix)); - wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(suffix)); + wrapper.write(Type.BYTE, flags); + wrapper.write(Type.STRING, nameTagVisibility); + wrapper.write(Type.STRING, collisionRule); + + wrapper.write(Type.BYTE, (byte) colour); } if (action == 0 || action == 3 || action == 4) { From fadebbc17b8ff91cc3bdaead117d106fe82af2dc Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 14:18:24 +0100 Subject: [PATCH 2/7] rewrite items in metadata --- .../protocol1_12_2to1_13/packets/EntityPackets1_13.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 99438011..205335d5 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -13,6 +13,7 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMapping; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping; import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12; import us.myles.ViaVersion.api.remapper.PacketHandler; @@ -399,6 +400,12 @@ public class EntityPackets1_13 extends EntityRewriter { } } + // Rewrite items + else if (typeId == 6) { + meta.setMetaType(MetaType1_12.Slot); + BlockItemPackets1_13.toClient((Item) meta.getValue()); + } + // Discontinue particles else if (typeId == 15) { meta.setMetaType(MetaType1_12.Discontinued); From 88e83f9aade77ea44432653148ae5b217a550486 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 14:37:48 +0100 Subject: [PATCH 3/7] use ViaBackwards logger instead of ViaVersions --- .../block_entity_handlers/BannerHandler.java | 4 ++-- .../protocol1_12_2to1_13/data/BackwardsMappings.java | 2 +- .../protocol1_12_2to1_13/packets/BlockItemPackets1_13.java | 3 ++- .../providers/BackwardsBlockEntityProvider.java | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java index 8f4eb1de..dc51c327 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/block_entity_handlers/BannerHandler.java @@ -10,8 +10,8 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers; +import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler; -import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag; import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag; @@ -37,7 +37,7 @@ public class BannerHandler implements BackwardsBlockEntityHandler { int color = (blockId - WALL_BANNER_START) >> 2; tag.put(new IntTag("Base", (15 - color))); } else { - Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag); + ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag); } // Invert colors diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java index 42a8be00..27008c71 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java @@ -31,7 +31,7 @@ public class BackwardsMappings { us.myles.viaversion.libs.gson.JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json"); us.myles.viaversion.libs.gson.JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json"); - Via.getPlatform().getLogger().info("Loading block mapping..."); + ViaBackwards.getPlatform().getLogger().info("Loading block mapping..."); blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates")); } 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 6125aa0b..f153af26 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 @@ -10,6 +10,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets; +import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.api.rewriters.Rewriter; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings; @@ -42,7 +43,7 @@ public class BlockItemPackets1_13 extends Rewriter { if (newId != -1) return newId; - Via.getPlatform().getLogger().warning("Missing block completely " + oldId); + ViaBackwards.getPlatform().getLogger().warning("Missing block completely " + oldId); // Default stone return 1 << 4; } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java index 7b29ab28..3792a978 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java @@ -10,6 +10,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers; +import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.*; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage; import us.myles.ViaVersion.api.Via; @@ -54,7 +55,7 @@ public class BackwardsBlockEntityProvider implements Provider { BackwardsBlockEntityHandler handler = handlers.get(id); if (handler == null) { if (Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag); + ViaBackwards.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag); } return tag; } @@ -63,7 +64,7 @@ public class BackwardsBlockEntityProvider implements Provider { if (!storage.contains(position)) { if (Via.getManager().isDebug()) { - Via.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag); + ViaBackwards.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag); } return tag; } From 5a3b59ce2923407e98a26c2e87a5a941c2085093 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 16:05:46 +0100 Subject: [PATCH 4/7] fix boss bar packet --- .../protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index 1f629fbc..cb57be17 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -95,6 +95,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.FLOAT); wrapper.passthrough(Type.VAR_INT); + wrapper.passthrough(Type.VAR_INT); short flags = wrapper.read(Type.UNSIGNED_BYTE); if ((flags & 0x04) != 0) flags |= 0x02; wrapper.write(Type.UNSIGNED_BYTE, flags); From 0018159c896c8bd8c75932fcece11061bd1a5ee0 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 21:12:48 +0100 Subject: [PATCH 5/7] fix tab complete --- .../protocol1_12_2to1_13/packets/PlayerPacket1_13.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 679a48ee..ea62045a 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 @@ -184,8 +184,9 @@ public class PlayerPacket1_13 extends Rewriter { // Ignore fields wrapper.read(Type.BOOLEAN); - wrapper.read(Type.OPTIONAL_POSITION); - + if (wrapper.read(Type.BOOLEAN)) { + wrapper.read(Type.POSITION); + } } }); } From 34ed045ba6ebc7640980fdbd92f7b754008ed616 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 21:35:40 +0100 Subject: [PATCH 6/7] arrow metadata fix --- .../protocol1_12_2to1_13/packets/EntityPackets1_13.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 205335d5..8c3b8d26 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -464,8 +464,13 @@ public class EntityPackets1_13 extends EntityRewriter { // Remove boat splash timer registerMetaHandler().filter(EntityType.BOAT, 12).removed(); + //Remove shooter UUID + registerMetaHandler().filter(EntityType.ABSTRACT_ARROW, true, 7).removed(); + + registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(8); + // Remove Trident special loyalty level - registerMetaHandler().filter(EntityType.TRIDENT, 7).removed(); + registerMetaHandler().filter(EntityType.TRIDENT, 8).removed(); // Handle new wolf colors registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> { From 3b2128acaad02bedfdbdfa017ca62c166dd2dc44 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Mon, 21 Jan 2019 22:16:35 +0100 Subject: [PATCH 7/7] fix metadata index --- .../protocol1_12_2to1_13/packets/EntityPackets1_13.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 8c3b8d26..e93d279e 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -467,7 +467,7 @@ public class EntityPackets1_13 extends EntityRewriter { //Remove shooter UUID registerMetaHandler().filter(EntityType.ABSTRACT_ARROW, true, 7).removed(); - registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(8); + registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(7); // Remove Trident special loyalty level registerMetaHandler().filter(EntityType.TRIDENT, 8).removed();