From 3c436c025987f99ef85a1122dd57ecbf671c1210 Mon Sep 17 00:00:00 2001 From: Nassim <28825609+KennyTV@users.noreply.github.com> Date: Tue, 10 Sep 2019 18:09:11 +0200 Subject: [PATCH] Fix entity equipment packet for 1.9+ clients (#1449) --- .../protocol1_9to1_8/packets/EntityPackets.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java index 4792a00e7..8ccb52b3c 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java @@ -140,7 +140,15 @@ public class EntityPackets { // 1 - Slot ID map(Type.SHORT, new ValueTransformer(Type.VAR_INT) { @Override - public Integer transform(PacketWrapper wrapper, Short slot) { + public Integer transform(PacketWrapper wrapper, Short slot) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + int receiverId = wrapper.user().get(EntityTracker.class).getEntityID(); + // Normally, 0 = hand and 1-4 = armor + // ... but if the sent id is equal to the receiver's id, 0-3 will instead mark the armor slots + // (In 1.9+, every client treats the received the same: 0=hand, 1=offhand, 2-5=armor) + if (entityId == receiverId) { + return slot.intValue() + 2; + } return slot > 0 ? slot.intValue() + 1 : slot.intValue(); } });