From aef8eca7903823b7a3097d29a7a814866f136a7c Mon Sep 17 00:00:00 2001 From: HugoDaBosss Date: Tue, 8 Mar 2016 21:48:21 +0100 Subject: [PATCH] Fix animation for bows --- .../myles/ViaVersion/metadata/MetaIndex.java | 1 + .../ViaVersion/metadata/MetadataRewriter.java | 8 +++++++ .../us/myles/ViaVersion/metadata/Type.java | 3 ++- .../transformers/IncomingTransformer.java | 21 +++++++++---------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/metadata/MetaIndex.java b/src/main/java/us/myles/ViaVersion/metadata/MetaIndex.java index 35e0b61d0..5ca5c2d27 100644 --- a/src/main/java/us/myles/ViaVersion/metadata/MetaIndex.java +++ b/src/main/java/us/myles/ViaVersion/metadata/MetaIndex.java @@ -33,6 +33,7 @@ public enum MetaIndex { PLAYER_HUMAN_BYTE(HumanEntity.class, 16, Type.Byte, NewType.Discontinued), // unused on 1.8 PLAYER_ADDITIONAL_HEARTS(HumanEntity.class, 17, Type.Float, 10, NewType.Float), PLAYER_SCORE(HumanEntity.class, 18, Type.Int, 11, NewType.VarInt), + PLAYER_HAND(HumanEntity.class, -1, Type.NonExistent, 5, NewType.Byte), // new in 1.9 // horse HORSE_INFO(Horse.class, 16, Type.Int, 12, NewType.Byte), HORSE_TYPE(Horse.class, 19, Type.Byte, 13, NewType.VarInt), diff --git a/src/main/java/us/myles/ViaVersion/metadata/MetadataRewriter.java b/src/main/java/us/myles/ViaVersion/metadata/MetadataRewriter.java index 8727bcb2b..bbc17cc52 100644 --- a/src/main/java/us/myles/ViaVersion/metadata/MetadataRewriter.java +++ b/src/main/java/us/myles/ViaVersion/metadata/MetadataRewriter.java @@ -40,6 +40,14 @@ public class MetadataRewriter { if (metaIndex.getOldType() == Type.Int) { output.writeByte(((Integer) value).byteValue()); } + if (metaIndex == MetaIndex.ENTITY_STATUS && type == EntityType.PLAYER) { + output.writeByte(MetaIndex.PLAYER_HAND.getNewIndex()); + output.writeByte(MetaIndex.PLAYER_HAND.getNewType().getTypeID()); + if((((Byte)value) & 0x10) == 0x10) //Player eating/aiming/drinking + output.writeByte(1); //Using main hand + else + output.writeByte(0); //Not using any hand to stop animation + } break; case OptUUID: String owner = (String) value; diff --git a/src/main/java/us/myles/ViaVersion/metadata/Type.java b/src/main/java/us/myles/ViaVersion/metadata/Type.java index b5cb8a967..5c0e9d20b 100644 --- a/src/main/java/us/myles/ViaVersion/metadata/Type.java +++ b/src/main/java/us/myles/ViaVersion/metadata/Type.java @@ -13,7 +13,8 @@ public enum Type { String(4), Slot(5), Position(6), - Rotation(7); + Rotation(7), + NonExistent(-1); private final int typeID; public static Type byId(int id) { diff --git a/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java index 181479323..67c5a6d11 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java @@ -275,14 +275,13 @@ public class IncomingTransformer { } catch (Exception e) { e.printStackTrace(); } - - short curX = input.readUnsignedByte(); - output.writeByte(curX); - short curY = input.readUnsignedByte(); - output.writeByte(curY); - short curZ = input.readUnsignedByte(); - output.writeByte(curZ); - return; + short curX = input.readUnsignedByte(); + output.writeByte(curX); + short curY = input.readUnsignedByte(); + output.writeByte(curY); + short curZ = input.readUnsignedByte(); + output.writeByte(curZ); + return; } if (packet == PacketType.PLAY_USE_ITEM) { int hand = PacketUtil.readVarInt(input); @@ -317,9 +316,9 @@ public class IncomingTransformer { e.printStackTrace(); } - output.writeByte(-1); - output.writeByte(-1); - output.writeByte(-1); + output.writeByte(0); //Is zero in 1.8, not -1 + output.writeByte(0); + output.writeByte(0); return; } if (packet == PacketType.PLAY_CREATIVE_INVENTORY_ACTION) {