Unify entity spawn packet sending
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include "Player.h"
|
||||
#include "ArrowEntity.h"
|
||||
#include "../Chunk.h"
|
||||
#include "../ClientHandle.h"
|
||||
|
||||
|
||||
|
||||
@@ -161,16 +160,6 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
|
||||
|
||||
|
||||
|
||||
void cArrowEntity::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendSpawnObject(*this, m_ProjectileKind, static_cast<int>(m_CreatorData.m_UniqueID + 1));
|
||||
a_Client.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cArrowEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
Super::Tick(a_Dt, a_Chunk);
|
||||
|
||||
@@ -108,7 +108,6 @@ protected:
|
||||
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
|
||||
virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
|
||||
virtual void CollectedBy(cPlayer & a_Player) override;
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||
|
||||
}; // tolua_export
|
||||
|
||||
@@ -33,7 +33,7 @@ cBoat::cBoat(Vector3d a_Pos, eMaterial a_Material) :
|
||||
|
||||
void cBoat::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnVehicle(*this, 1);
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ cEnderCrystal::cEnderCrystal(Vector3d a_Pos):
|
||||
|
||||
void cEnderCrystal::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnObject(*this, 51, 0);
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ cFallingBlock::cFallingBlock(Vector3d a_Position, BLOCKTYPE a_BlockType, NIBBLET
|
||||
|
||||
void cFallingBlock::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnFallingBlock(*this);
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ cFloater::cFloater(Vector3d a_Pos, Vector3d a_Speed, UInt32 a_PlayerID, int a_Co
|
||||
|
||||
void cFloater::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendSpawnObject(*this, 90, static_cast<int>(m_PlayerID));
|
||||
a_Client.SendSpawnEntity(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT))
|
||||
&& (m_World->GetBlockMeta(POSX_TOINT, POSY_TOINT, POSZ_TOINT) == 0))
|
||||
{
|
||||
if ((!m_CanPickupItem) && (m_AttachedMobID == cEntity::INVALID_ID)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
|
||||
if (!m_CanPickupItem && (m_AttachedMobID == cEntity::INVALID_ID)) // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
|
||||
{
|
||||
if (m_CountDownTime <= 0)
|
||||
{
|
||||
|
||||
@@ -95,10 +95,6 @@ void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer)
|
||||
void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
Super::SpawnOn(a_ClientHandle);
|
||||
a_ClientHandle.SendSpawnObject(*this, 71, GetProtocolFacing());
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
a_ClientHandle.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void cLeashKnot::GetDrops(cItems & a_Items, cEntity * a_Killer)
|
||||
void cLeashKnot::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
Super::SpawnOn(a_ClientHandle);
|
||||
a_ClientHandle.SendSpawnObject(*this, 77, GetProtocolFacing());
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
a_ClientHandle.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ cMinecart::cMinecart(ePayload a_Payload, Vector3d a_Pos):
|
||||
|
||||
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnVehicle(*this, 10, static_cast<char>(m_Payload)); // 10 = Minecarts
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
a_ClientHandle.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ cPickup::cPickup(Vector3d a_Pos, const cItem & a_Item, bool IsPlayerCreated, Vec
|
||||
|
||||
void cPickup::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendPickupSpawn(*this);
|
||||
a_Client.SendSpawnEntity(*this);
|
||||
a_Client.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -283,7 +283,6 @@ std::unique_ptr<cProjectileEntity> cProjectileEntity::Create(
|
||||
|
||||
return cpp14::make_unique<cFireworkEntity>(a_Creator, a_Pos, *a_Item);
|
||||
}
|
||||
case pkFishingFloat: break;
|
||||
}
|
||||
|
||||
LOGWARNING("%s: Unknown projectile kind: %d", __FUNCTION__, a_Kind);
|
||||
@@ -347,7 +346,6 @@ AString cProjectileEntity::GetMCAClassName(void) const
|
||||
case pkSplashPotion: return "SplashPotion";
|
||||
case pkWitherSkull: return "WitherSkull";
|
||||
case pkFirework: return "Firework";
|
||||
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?
|
||||
}
|
||||
UNREACHABLE("Unsupported projectile kind");
|
||||
}
|
||||
@@ -443,8 +441,7 @@ void cProjectileEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a
|
||||
|
||||
void cProjectileEntity::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
// Default spawning - use the projectile kind to spawn an object:
|
||||
a_Client.SendSpawnObject(*this, m_ProjectileKind, 12);
|
||||
a_Client.SendSpawnEntity(*this);
|
||||
a_Client.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,20 +29,19 @@ class cProjectileEntity :
|
||||
|
||||
public:
|
||||
|
||||
/** The kind of the projectile. The numbers correspond to the network type ID used for spawning them in the protocol. */
|
||||
/** The kind of the projectile. */
|
||||
enum eKind
|
||||
{
|
||||
pkArrow = 60,
|
||||
pkSnowball = 61,
|
||||
pkEgg = 62,
|
||||
pkGhastFireball = 63,
|
||||
pkFireCharge = 64,
|
||||
pkEnderPearl = 65,
|
||||
pkExpBottle = 75,
|
||||
pkSplashPotion = 73,
|
||||
pkFirework = 76,
|
||||
pkWitherSkull = 66,
|
||||
pkFishingFloat = 90,
|
||||
pkArrow,
|
||||
pkSnowball,
|
||||
pkEgg,
|
||||
pkGhastFireball,
|
||||
pkFireCharge,
|
||||
pkEnderPearl,
|
||||
pkExpBottle,
|
||||
pkSplashPotion,
|
||||
pkFirework,
|
||||
pkWitherSkull,
|
||||
} ;
|
||||
|
||||
// tolua_end
|
||||
@@ -93,7 +92,7 @@ public:
|
||||
/** Returns the unique ID of the entity who created this projectile
|
||||
May return an ID <0
|
||||
*/
|
||||
UInt32 GetCreatorUniqueID(void) { return m_CreatorData.m_UniqueID; }
|
||||
UInt32 GetCreatorUniqueID(void) const { return m_CreatorData.m_UniqueID; }
|
||||
|
||||
/** Returns the name of the player that created the projectile
|
||||
Will be empty for non-player creators
|
||||
@@ -142,6 +141,6 @@ protected:
|
||||
// cEntity overrides:
|
||||
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
virtual void SpawnOn(cClientHandle & a_Client) final override;
|
||||
|
||||
} ; // tolua_export
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "SplashPotionEntity.h"
|
||||
#include "Pawn.h"
|
||||
#include "../ClientHandle.h"
|
||||
#include "../EffectID.h"
|
||||
|
||||
|
||||
@@ -89,17 +88,3 @@ void cSplashPotionEntity::Splash(Vector3d a_HitPos)
|
||||
m_PotionColor
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client)
|
||||
{
|
||||
a_Client.SendSpawnObject(*this, 73, m_PotionColor);
|
||||
a_Client.SendEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -84,8 +84,6 @@ protected:
|
||||
@param a_HitPos The position where the potion will splash */
|
||||
void Splash(Vector3d a_HitPos);
|
||||
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
|
||||
private:
|
||||
/** Time in ticks to wait for the hit animation to begin before destroying */
|
||||
int m_DestroyTimer;
|
||||
|
||||
@@ -22,8 +22,8 @@ cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
|
||||
|
||||
void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnObject(*this, 50, 1); // 50 means TNT
|
||||
m_bDirtyOrientation = false;
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
m_bDirtyOrientation = false; // TODO: why?
|
||||
m_bDirtyHead = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user