diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-19 23:14:45 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-19 23:14:45 +0200 |
commit | 674fe1e955f729e8328772313c45fe76857ec835 (patch) | |
tree | 49511bc948f76825ee1ad6be310034f261b35e90 /source/cPawn.cpp | |
parent | Almost all packets' handling is now rewritten not to use cPacket descendants elsewhere than in cClientHandle. (diff) | |
download | cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar.gz cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar.bz2 cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar.lz cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar.xz cuberite-674fe1e955f729e8328772313c45fe76857ec835.tar.zst cuberite-674fe1e955f729e8328772313c45fe76857ec835.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPawn.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/source/cPawn.cpp b/source/cPawn.cpp index 5b2b475c0..d8a9d03be 100644 --- a/source/cPawn.cpp +++ b/source/cPawn.cpp @@ -9,13 +9,8 @@ #include "cPluginManager.h" #include "Vector3d.h" #include "BlockID.h" - #include "Defines.h" -#include "packets/cPacket_TeleportEntity.h" -#include "packets/cPacket_EntityStatus.h" -#include "packets/cPacket_Metadata.h" - @@ -62,27 +57,34 @@ void cPawn::Heal( int a_Health ) -void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator ) +void cPawn::TakeDamage(int a_Damage, cEntity * a_Instigator) { TakeDamageInfo TDI; TDI.Damage = a_Damage; TDI.Instigator = a_Instigator; - cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI ); + cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_TAKE_DAMAGE, 2, this, &TDI); - if( TDI.Damage == 0 ) return; - if( m_Health <= 0 ) return; // Can't take damage if already dead + if (TDI.Damage == 0) + { + return; + } + if (m_Health <= 0) + { + // Can't take damage if already dead + return; + } m_Health -= (short)TDI.Damage; - if( m_Health < 0 ) m_Health = 0; + if (m_Health < 0) + { + m_Health = 0; + } - cPacket_EntityStatus Status; - Status.m_UniqueID = GetUniqueID(); - Status.m_Status = cPacket_EntityStatus::STATUS_TAKEDAMAGE; - m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, Status); + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_HURT); if (m_Health <= 0) { - KilledBy( TDI.Instigator ); + KilledBy(TDI.Instigator); } } @@ -90,7 +92,7 @@ void cPawn::TakeDamage( int a_Damage, cEntity* a_Instigator ) -void cPawn::KilledBy( cEntity* a_Killer ) +void cPawn::KilledBy(cEntity * a_Killer) { m_Health = 0; @@ -99,19 +101,16 @@ void cPawn::KilledBy( cEntity* a_Killer ) return; // Give plugins a chance to 'unkill' the pawn. } - cPacket_EntityStatus Status; - Status.m_UniqueID = GetUniqueID(); - Status.m_Status = cPacket_EntityStatus::STATUS_DIE; - m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, Status); + m_World->BroadcastEntityStatus(*this, ENTITY_STATUS_DEAD); } -void cPawn::TeleportToEntity( cEntity* a_Entity ) +void cPawn::TeleportToEntity(cEntity * a_Entity) { - TeleportTo( a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ() ); + TeleportTo(a_Entity->GetPosX(), a_Entity->GetPosY(), a_Entity->GetPosZ()); } @@ -148,8 +147,7 @@ void cPawn::SetMetaData(MetaData a_MetaData) { //Broadcast new status to clients in the chunk m_MetaData = a_MetaData; - cPacket_Metadata md(a_MetaData, GetUniqueID()); - m_World->BroadcastToChunk(m_ChunkX, m_ChunkY, m_ChunkZ, md); + m_World->BroadcastMetadata(*this); } |