From 1edc6c8601f9d00751bf7c9f7fcc69d1e18bb46a Mon Sep 17 00:00:00 2001 From: Persson-dev <66266021+Persson-dev@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:30:09 +0100 Subject: Add skeleton bow pulling animation (#5355) * Added basic skeleton bow animation * Fixing style --- src/Protocol/Protocol_1_10.cpp | 14 +++++++++++++- src/Protocol/Protocol_1_11.cpp | 14 +++++++++++++- src/Protocol/Protocol_1_12.cpp | 14 +++++++++++++- src/Protocol/Protocol_1_13.cpp | 14 ++++++++++++-- src/Protocol/Protocol_1_9.cpp | 11 +++++++++++ 5 files changed, 62 insertions(+), 5 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index 9f4413576..4f3e1a52b 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -795,6 +795,19 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ break; } // case mtSheep + case mtSkeleton: + { + auto & Skeleton = static_cast(a_Mob); + a_Pkt.WriteBEUInt8(LIVING_ACTIVE_HAND); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); + a_Pkt.WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00); + + a_Pkt.WriteBEUInt8(SKELETON_ARMS_SWINGING); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); + a_Pkt.WriteBool(Skeleton.IsChargingBow()); + break; + } // case mtSkeleton + case mtSlime: { auto & Slime = static_cast(a_Mob); @@ -958,7 +971,6 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ case mtIronGolem: case mtMooshroom: case mtSilverfish: - case mtSkeleton: case mtSnowGolem: case mtStray: case mtSpider: diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp index 30935574b..7a9a53e6f 100644 --- a/src/Protocol/Protocol_1_11.cpp +++ b/src/Protocol/Protocol_1_11.cpp @@ -1102,6 +1102,19 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ break; } // case mtSheep + case mtSkeleton: + { + auto & Skeleton = static_cast(a_Mob); + a_Pkt.WriteBEUInt8(LIVING_ACTIVE_HAND); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); + a_Pkt.WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00); + + a_Pkt.WriteBEUInt8(ABSTRACT_SKELETON_ARMS_SWINGING); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); + a_Pkt.WriteBool(Skeleton.IsChargingBow()); + break; + } // case mtSkeleton + case mtSlime: { auto & Slime = static_cast(a_Mob); @@ -1260,7 +1273,6 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ case mtIronGolem: case mtMooshroom: case mtSilverfish: - case mtSkeleton: case mtStray: case mtSpider: case mtSquid: diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp index d0e77ae80..c7f0ee31a 100644 --- a/src/Protocol/Protocol_1_12.cpp +++ b/src/Protocol/Protocol_1_12.cpp @@ -788,6 +788,19 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo break; } // case mtSheep + case mtSkeleton: + { + auto & Skeleton = static_cast(a_Mob); + a_Pkt.WriteBEUInt8(LIVING_ACTIVE_HAND); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); + a_Pkt.WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00); + + a_Pkt.WriteBEUInt8(ABSTRACT_SKELETON_ARMS_SWINGING); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); + a_Pkt.WriteBool(Skeleton.IsChargingBow()); + break; + } // case mtSkeleton + case mtSlime: { auto & Slime = static_cast(a_Mob); @@ -967,7 +980,6 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtGiant: case mtSilverfish: - case mtSkeleton: case mtSquid: { // Mobs with no extra fields diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index f6919388c..80a1e9df1 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -337,6 +337,7 @@ UInt8 cProtocol_1_13::GetEntityMetadataID(EntityMetadata a_Metadata) const case EntityMetadata::IllagerFlags: return Insentient; case EntityMetadata::SpeIlagerSpell: return Insentient + 1; case EntityMetadata::VexFlags: return Insentient; + case EntityMetadata::AbstractSkeletonArmsSwinging: return Insentient; case EntityMetadata::SpiderClimbing: return Insentient; case EntityMetadata::WitchAggresive: return Insentient; case EntityMetadata::WitherFirstHeadTarget: return Insentient; @@ -366,7 +367,6 @@ UInt8 cProtocol_1_13::GetEntityMetadataID(EntityMetadata a_Metadata) const case EntityMetadata::EntityPose: case EntityMetadata::AreaEffectCloudParticleParameter1: case EntityMetadata::AreaEffectCloudParticleParameter2: - case EntityMetadata::AbstractSkeletonArmsSwinging: case EntityMetadata::ZombieUnusedWasType: break; } UNREACHABLE("Retrieved invalid metadata for protocol"); @@ -1184,6 +1184,17 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo break; } // case mtSheep + case mtSkeleton: + { + auto & Skeleton = static_cast(a_Mob); + WriteEntityMetadata(a_Pkt, EntityMetadata::LivingActiveHand, EntityMetadataType::Byte); + a_Pkt.WriteBEUInt8(Skeleton.IsChargingBow() ? 0x01 : 0x00); + + WriteEntityMetadata(a_Pkt, EntityMetadata::AbstractSkeletonArmsSwinging, EntityMetadataType::Boolean); + a_Pkt.WriteBool(Skeleton.IsChargingBow()); + break; + } // case mtSkeleton + case mtSlime: { auto & Slime = static_cast(a_Mob); @@ -1354,7 +1365,6 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtGiant: case mtSilverfish: - case mtSkeleton: case mtSquid: case mtWitherSkeleton: { diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 2cc087682..a36e3f53d 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -2110,9 +2110,20 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M case mtSkeleton: { + auto & Skeleton = static_cast(a_Mob); a_Pkt.WriteBEUInt8(11); a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); a_Pkt.WriteVarInt32(0); + + // Index 5 and 12 used for charging bow client animation. + a_Pkt.WriteBEUInt8(5); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); + a_Pkt.WriteBEInt8(0x02 | (Skeleton.IsChargingBow() ? 0x01 : 0x00)); + + a_Pkt.WriteBEUInt8(12); + a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); + a_Pkt.WriteBool(Skeleton.IsChargingBow()); + break; } case mtSlime: -- cgit v1.2.3