From a7126b39dc8a1666780bde9aeb74089715ecc125 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Tue, 21 May 2019 22:05:36 +0200 Subject: [PATCH] fix horse armor --- .../Protocol1_13_2To1_14.java | 6 ++-- .../packets/BlockItemPackets1_14.java | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java index 91abf59d..9afa969a 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java @@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; @Getter public class Protocol1_13_2To1_14 extends BackwardsProtocol { private BlockItemPackets1_14 blockItemPackets; - private EntityPackets1_14 entityPacket; + private EntityPackets1_14 entityPackets; static { BackwardsMappings.init(); @@ -32,8 +32,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { protected void registerPackets() { blockItemPackets = new BlockItemPackets1_14(); blockItemPackets.register(this); - entityPacket = new EntityPackets1_14(); - entityPacket.register(this); + entityPackets = new EntityPackets1_14(); + entityPackets.register(this); new PlayerPackets1_14().register(this); new SoundPackets1_14().register(this); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index deb5f193..e9e74104 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -2,6 +2,9 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets; import com.google.common.collect.ImmutableSet; import nl.matsv.viabackwards.ViaBackwards; +import nl.matsv.viabackwards.api.entities.storage.EntityTracker; +import nl.matsv.viabackwards.api.entities.types.AbstractEntityType; +import nl.matsv.viabackwards.api.entities.types.EntityType1_14; import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import us.myles.ViaVersion.api.PacketWrapper; @@ -10,9 +13,12 @@ import us.myles.ViaVersion.api.minecraft.Environment; import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; 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_13_2; 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.api.type.types.version.Types1_13; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; @@ -26,7 +32,9 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag; import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag; import us.myles.viaversion.libs.opennbt.tag.builtin.Tag; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Set; public class BlockItemPackets1_14 extends BlockItemRewriter { @@ -224,6 +232,31 @@ public class BlockItemPackets1_14 extends BlockItemRewriter 3) { + ViaBackwards.getPlatform().getLogger().warning("Received invalid horse armor: " + item); + wrapper.cancel(); + return; + } + List metadataList = new ArrayList<>(); + metadataList.add(new Metadata(16, MetaType1_13_2.VarInt, armorType)); + wrapper.write(Types1_13.METADATA_LIST, metadataList); + } + } + }); } });