From 66c211c33afa1dc99f6dc3a03119ad0b99ce50c5 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 9 Apr 2021 23:17:01 +0100 Subject: Unify multiprotocol entity animations --- src/Entities/Entity.cpp | 14 +++++++++++--- src/Entities/Entity.h | 41 ----------------------------------------- src/Entities/FireworkEntity.cpp | 2 +- src/Entities/Pawn.cpp | 2 +- src/Entities/Player.cpp | 5 ++--- 5 files changed, 15 insertions(+), 49 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c8a6b8ef9..7bb53bd2a 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -525,7 +525,15 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) SetSpeed(a_TDI.Knockback); } - m_World->BroadcastEntityStatus(*this, esGenericHurt); + m_World->BroadcastEntityAnimation(*this, [&a_TDI] + { + switch (a_TDI.DamageType) + { + case eDamageType::dtBurning: return EntityAnimation::PawnBurns; + case eDamageType::dtDrowning: return EntityAnimation::PawnDrowns; + default: return EntityAnimation::PawnHurts; + } + }()); m_InvulnerableTicks = 10; @@ -797,7 +805,7 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI) // If the victim is a player the hook is handled by the cPlayer class if (!IsPlayer()) { - AString emptystring = AString(""); + AString emptystring; cRoot::Get()->GetPluginManager()->CallHookKilled(*this, a_TDI, emptystring); } @@ -813,7 +821,7 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI) m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ()); } - m_World->BroadcastEntityStatus(*this, esGenericDead); + m_World->BroadcastEntityAnimation(*this, EntityAnimation::PawnDies); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index c3ccaa228..db526045e 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -109,47 +109,6 @@ public: // tolua_end - enum eEntityStatus - { - // TODO: Investigate 0, 1, and 5 as Wiki.vg is not certain - - // Entity becomes coloured red - esGenericHurt = 2, - // Entity plays death animation (entity falls to ground) - esGenericDead = 3, - // Iron Golem plays attack animation (arms lift and fall) - esIronGolemAttacking = 4, - // Wolf taming particles spawn (smoke) - esWolfTaming = 6, - // Wolf tamed particles spawn (hearts) - esWolfTamed = 7, - // Wolf plays water removal animation (shaking and water particles) - esWolfDryingWater = 8, - // Informs client that eating was accepted - esPlayerEatingAccepted = 9, - // Sheep plays eating animation (head lowers to ground) - esSheepEating = 10, - // Iron Golem holds gift to villager children - esIronGolemGivingPlant = 11, - // Villager spawns heart particles - esVillagerBreeding = 12, - // Villager spawns thunderclound particles - esVillagerAngry = 13, - // Villager spawns green crosses - esVillagerHappy = 14, - // Witch spawns magic particle (TODO: investigation into what this is) - esWitchMagicking = 15, - - // It seems 16 (zombie conversion) is now done with metadata - - // Informs client to explode a firework based on its metadata - esFireworkExploding = 17, - // Passive mob is in "love mode" - esMobInLove = 18, - // Plays totem of undying animation and sound - esTotemOfUndying = 35, - } ; - static const int FIRE_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in fire static const int FIRE_DAMAGE = 1; ///< Damage to deal when standing in fire static const int LAVA_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in lava diff --git a/src/Entities/FireworkEntity.cpp b/src/Entities/FireworkEntity.cpp index eb386cdfc..03db96d91 100644 --- a/src/Entities/FireworkEntity.cpp +++ b/src/Entities/FireworkEntity.cpp @@ -74,7 +74,7 @@ void cFireworkEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (m_TicksToExplosion <= 0) { // TODO: Notify the plugins - m_World->BroadcastEntityStatus(*this, esFireworkExploding); + m_World->BroadcastEntityAnimation(*this, EntityAnimation::FireworkRocketExplodes); Destroy(); return; } diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index cc11323e1..5476db468 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -115,7 +115,7 @@ void cPawn::KilledBy(TakeDamageInfo & a_TDI) // Is death eligible for totem reanimation? if (DeductTotem(a_TDI.DamageType)) { - m_World->BroadcastEntityStatus(*this, esTotemOfUndying); + m_World->BroadcastEntityAnimation(*this, EntityAnimation::PawnTotemActivates); AddEntityEffect(cEntityEffect::effAbsorption, 100, 1); AddEntityEffect(cEntityEffect::effRegeneration, 900, 1); diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 8c047c533..563a1cb97 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -498,8 +498,7 @@ void cPlayer::StartEating(void) // Set the timer: m_EatingFinishTick = m_World->GetWorldAge() + EATING_TICKS; - // Send the packets: - m_World->BroadcastEntityAnimation(*this, 3); + // Send the packet: m_World->BroadcastEntityMetadata(*this); } @@ -513,7 +512,7 @@ void cPlayer::FinishEating(void) m_EatingFinishTick = -1_tick; // Send the packets: - m_ClientHandle->SendEntityStatus(*this, esPlayerEatingAccepted); + m_ClientHandle->SendEntityAnimation(*this, EntityAnimation::PlayerFinishesEating); m_World->BroadcastEntityMetadata(*this); // consume the item: -- cgit v1.2.3