diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-11-04 22:53:37 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-11-04 22:53:37 +0100 |
commit | 3d00e52d42edc69eb777c90c6e6f479a5a473598 (patch) | |
tree | 9ed2245653c77b7de86678c345254fe70342126e /src/Entities | |
parent | More player speed/position overrides (diff) | |
download | cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar.gz cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar.bz2 cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar.lz cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar.xz cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.tar.zst cuberite-3d00e52d42edc69eb777c90c6e6f479a5a473598.zip |
Diffstat (limited to 'src/Entities')
44 files changed, 198 insertions, 315 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index c265c5043..005c0f44a 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -8,8 +8,8 @@ -cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5), +cArrowEntity::cArrowEntity(CreateEntityInfo Info, cEntity * a_Creator) : + super(Info, pkArrow, a_Creator, 0.5, 0.5), m_PickupState(psNoPickup), m_DamageCoeff(2), m_IsCritical(false), @@ -17,10 +17,8 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a m_HitGroundTimer(0), m_HasTeleported(false), m_bIsCollected(false), - m_HitBlockPos(Vector3i(0, 0, 0)) + m_HitBlockPos(0, 0, 0) { - SetSpeed(a_Speed); - SetMass(0.1); SetYawFromSpeed(); SetPitchFromSpeed(); LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}", @@ -34,7 +32,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) : - super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5), + super(CreateEntityInfo{ a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), Vector3d(0, 0, 0) }, pkArrow, &a_Player, 0.5, 0.5), m_PickupState(psInSurvivalOrCreative), m_DamageCoeff(2), m_IsCritical((a_Force >= 1)), diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index a1e7a17e7..4822ae690 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -32,7 +32,7 @@ public: CLASS_PROTODEF(cArrowEntity) /// Creates a new arrow with psNoPickup state and default damage modifier coeff - cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cArrowEntity(CreateEntityInfo Info, cEntity * a_Creator); /// Creates a new arrow as shot by a player, initializes it from the player object cArrowEntity(cPlayer & a_Player, double a_Force); diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 328a70846..a21e48e25 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -13,12 +13,10 @@ -cBoat::cBoat(double a_X, double a_Y, double a_Z) : - super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7) +cBoat::cBoat(CreateEntityInfo a_Info) : + super(etBoat, a_Info, 0.98, 0.7, 6) { SetMass(20.f); - SetMaxHealth(6); - SetHealth(6); } diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index 8de88d165..89dd63987 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -30,7 +30,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override; - cBoat(double a_X, double a_Y, double a_Z); + cBoat(CreateEntityInfo a_Info); } ; diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp index 30df2c110..bf879373e 100644 --- a/src/Entities/EnderCrystal.cpp +++ b/src/Entities/EnderCrystal.cpp @@ -10,10 +10,9 @@ -cEnderCrystal::cEnderCrystal(double a_X, double a_Y, double a_Z) - : cEntity(etEnderCrystal, a_X, a_Y, a_Z, 1.0, 1.0) +cEnderCrystal::cEnderCrystal(CreateEntityInfo a_Info) + : cEntity(etEnderCrystal, a_Info, 1.0, 1.0, 5) { - SetMaxHealth(5); } diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h index c98c3b681..97f218967 100644 --- a/src/Entities/EnderCrystal.h +++ b/src/Entities/EnderCrystal.h @@ -17,7 +17,7 @@ class cEnderCrystal : public: CLASS_PROTODEF(cEnderCrystal) - cEnderCrystal(double a_X, double a_Y, double a_Z); + cEnderCrystal(CreateEntityInfo a_Info); private: diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 02fcd5f1b..3413dedcc 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -25,41 +25,41 @@ cCriticalSection cEntity::m_CSCount; -cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) - : m_UniqueID(0) - , m_Health(1) - , m_MaxHealth(1) - , m_AttachedTo(NULL) - , m_Attachee(NULL) - , m_bDirtyHead(true) - , m_bDirtyOrientation(true) - , m_bHasSentNoSpeed(true) - , m_bOnGround(false) - , m_Gravity(-9.81f) - , m_LastPos(a_X, a_Y, a_Z) - , m_IsInitialized(false) - , m_WorldTravellingFrom(NULL) - , m_EntityType(a_EntityType) - , m_World(NULL) - , m_IsFireproof(false) - , m_TicksSinceLastBurnDamage(0) - , m_TicksSinceLastLavaDamage(0) - , m_TicksSinceLastFireDamage(0) - , m_TicksLeftBurning(0) - , m_TicksSinceLastVoidDamage(0) - , m_IsSwimming(false) - , m_IsSubmerged(false) - , m_AirLevel(0) - , m_AirTickTimer(0) - , m_TicksAlive(0) - , m_HeadYaw(0.0) - , m_Rot(0.0, 0.0, 0.0) - , m_Pos(a_X, a_Y, a_Z) - , m_WaterSpeed(0, 0, 0) - , m_Mass (0.001) // Default 1g - , m_Width(a_Width) - , m_Height(a_Height) - , m_InvulnerableTicks(0) +cEntity::cEntity(CreateEntityInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height, int a_MaxHealth) : + m_UniqueID(0), + m_Health(a_Info.Health), + m_MaxHealth(a_MaxHealth), + m_AttachedTo(NULL), + m_Attachee(NULL), + m_bDirtyHead(true), + m_bDirtyOrientation(true), + m_bHasSentNoSpeed(true), + m_bOnGround(false), + m_Gravity(-9.81f), + m_LastPos(a_Info.Position), + m_IsInitialized(false), + m_WorldTravellingFrom(NULL), + m_EntityType(a_EntityType), + m_World(NULL), + m_IsFireproof(false), + m_TicksSinceLastBurnDamage(0), + m_TicksSinceLastLavaDamage(0), + m_TicksSinceLastFireDamage(0), + m_TicksLeftBurning(0), + m_TicksSinceLastVoidDamage(0), + m_IsSwimming(false), + m_IsSubmerged(false), + m_AirLevel(0), + m_AirTickTimer(0), + m_TicksAlive(0), + m_HeadYaw(0.0), + m_Rot(a_Info.Rotation), + m_Pos(a_Info.Position), + m_WaterSpeed(0, 0, 0), + m_Mass (0.001), // Default 1g + m_Width(a_Width), + m_Height(a_Height), + m_InvulnerableTicks(0) { cCSLock Lock(m_CSCount); m_EntityCount++; @@ -1338,7 +1338,7 @@ bool cEntity::DetectPortal() if (IsPlayer()) { cPlayer * Player = (cPlayer *)this; - Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z); + SetPosition(Player->GetLastBedPos()); Player->GetClientHandle()->SendRespawn(dimOverworld); } @@ -1598,25 +1598,6 @@ void cEntity::StopBurning(void) -void cEntity::TeleportToEntity(cEntity & a_Entity) -{ - TeleportToCoords(a_Entity.GetPosX(), a_Entity.GetPosY(), a_Entity.GetPosZ()); -} - - - - - -void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) -{ - SetPosition(a_PosX, a_PosY, a_PosZ); - m_World->BroadcastTeleportEntity(*this); -} - - - - - void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude) { // Process packet sending every two ticks @@ -1738,16 +1719,6 @@ bool cEntity::IsA(const char * a_ClassName) const -void cEntity::SetRot(const Vector3f & a_Rot) -{ - m_Rot = a_Rot; - m_bDirtyOrientation = true; -} - - - - - void cEntity::SetHeadYaw(double a_HeadYaw) { m_HeadYaw = a_HeadYaw; @@ -1830,6 +1801,7 @@ void cEntity::SetPosition(const Vector3d & a_Pos) + void cEntity::AddPosition(const Vector3d & a_AddPos) { m_Pos += a_AddPos; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 3d7177fd4..72546b1e5 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -63,6 +63,19 @@ struct TakeDamageInfo +struct CreateEntityInfo +{ + Vector3d Position; + Vector3d Speed; + Vector3d Rotation; + int Health; + int MaxHealth; +} ; + + + + + // tolua_begin class cEntity { @@ -83,10 +96,7 @@ public: etExpOrb, etFloater, etItemFrame, - etPainting, - - // Common variations - etMob = etMonster, // DEPRECATED, use etMonster instead! + etPainting } ; // tolua_end @@ -143,7 +153,7 @@ public: static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied - cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); + cEntity(CreateEntityInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height, int a_MaxHealth); virtual ~cEntity(); /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). @@ -190,7 +200,6 @@ public: double GetPosX (void) const { return m_Pos.x; } double GetPosY (void) const { return m_Pos.y; } double GetPosZ (void) const { return m_Pos.z; } - const Vector3d & GetRot (void) const { return m_Rot; } // OBSOLETE, use individual GetYaw(), GetPitch, GetRoll() components double GetYaw (void) const { return m_Rot.x; } // In degrees, [-180, +180) double GetPitch (void) const { return m_Rot.y; } // In degrees, [-180, +180), but normal client clips to [-90, +90] double GetRoll (void) const { return m_Rot.z; } // In degrees, unused in current client @@ -208,7 +217,6 @@ public: void SetHeight (double a_Height) { m_Height = a_Height; } void SetWidth (double a_Width) { m_Width = a_Width; } void SetMass (double a_Mass); - void SetRot (const Vector3f & a_Rot); // OBSOLETE, use individual SetYaw(), SetPitch(), SetRoll() components void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180) void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180) void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180) @@ -420,12 +428,6 @@ public: virtual void SpawnOn(cClientHandle & a_Client) = 0; // tolua_begin - - /// Teleports to the entity specified - virtual void TeleportToEntity(cEntity & a_Entity); - - /// Teleports to the coordinates specified - virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); /** Moves entity to specified world, taking a world pointer */ bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) { return DoMoveToWorld(a_World, a_ShouldSendRespawn); } @@ -479,7 +481,10 @@ public: int GetAirLevel(void) const { return m_AirLevel; } /** Gets number of ticks this entity has existed for */ - long int GetTicksAlive(void) const { return m_TicksAlive; } + long GetTicksAlive(void) const { return m_TicksAlive; } + + /** Sets number of ticks this entity has existed for */ + void SetTicksAlive(long a_TicksAlive) { m_TicksAlive = a_TicksAlive; } /** Gets the invulnerable ticks from the entity */ int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } diff --git a/src/Entities/ExpBottleEntity.cpp b/src/Entities/ExpBottleEntity.cpp index ee142a5a2..851617788 100644 --- a/src/Entities/ExpBottleEntity.cpp +++ b/src/Entities/ExpBottleEntity.cpp @@ -7,10 +7,9 @@ -cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +cExpBottleEntity::cExpBottleEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkExpBottle, a_Creator, 0.25, 0.25) { - SetSpeed(a_Speed); } diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h index d36110f97..5d9b328d0 100644 --- a/src/Entities/ExpBottleEntity.h +++ b/src/Entities/ExpBottleEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cExpBottleEntity) - cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cExpBottleEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index 73d5cbfed..65e7bcc2d 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -5,26 +5,10 @@ #include "../ClientHandle.h" -cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) - : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98) - , m_Reward(a_Reward) - , m_Timer(0.f) +cExpOrb::cExpOrb(CreateEntityInfo a_Info, int a_Reward) + : cEntity(a_Info, etExpOrb, 0.98, 0.98, 5), + m_Reward(a_Reward) { - SetMaxHealth(5); - SetHealth(5); -} - - - - - -cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward) - : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98) - , m_Reward(a_Reward) - , m_Timer(0.f) -{ - SetMaxHealth(5); - SetHealth(5); } @@ -69,9 +53,8 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) } HandlePhysics(a_Dt, a_Chunk); - m_Timer += a_Dt; - if (m_Timer >= 1000 * 60 * 5) // 5 minutes + if (GetTicksAlive() >= 20 * 60 * 5) // 5 minutes { - Destroy(true); + Destroy(); } } diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h index bdb9a5b19..ae487b1ef 100644 --- a/src/Entities/ExpOrb.h +++ b/src/Entities/ExpOrb.h @@ -18,19 +18,12 @@ public: CLASS_PROTODEF(cExpOrb) - cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward); - cExpOrb(const Vector3d & a_Pos, int a_Reward); + cExpOrb(CreateEntityInfo a_Info, int a_Reward); // Override functions virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void SpawnOn(cClientHandle & a_Client) override; - /** Returns the number of ticks that this entity has existed */ - int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export - - /** Set the number of ticks that this entity has existed */ - void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export - /** Get the exp amount */ int GetReward(void) const { return m_Reward; } // tolua_export @@ -39,7 +32,4 @@ public: protected: int m_Reward; - - /** The number of ticks that the entity has existed / timer between collect and destroy; in msec */ - float m_Timer; } ; // tolua_export diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index 111c5fa84..14a12ba7f 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -10,11 +10,10 @@ -cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) : - super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f, 0.98, 0.98), +cFallingBlock::cFallingBlock(CreateEntityInfo a_Info, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) : + super(a_Info, etFallingBlock, 0.98, 0.98, 1), m_BlockType(a_BlockType), - m_BlockMeta(a_BlockMeta), - m_OriginalPosition(a_BlockPosition) + m_BlockMeta(a_BlockMeta) { } diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h index c20fe8eb9..94d9e72e3 100644 --- a/src/Entities/FallingBlock.h +++ b/src/Entities/FallingBlock.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cFallingBlock) /// Creates a new falling block. a_BlockPosition is expected in world coords - cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); + cFallingBlock(CreateEntityInfo a_Info, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); BLOCKTYPE GetBlockType(void) const { return m_BlockType; } NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; } @@ -35,7 +35,6 @@ public: private: BLOCKTYPE m_BlockType; NIBBLETYPE m_BlockMeta; - Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords } ; diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp index aba32602f..f9993f96f 100644 --- a/src/Entities/FireChargeEntity.cpp +++ b/src/Entities/FireChargeEntity.cpp @@ -7,10 +7,9 @@ -cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkFireCharge, a_Creator, a_X, a_Y, a_Z, 0.3125, 0.3125) +cFireChargeEntity::cFireChargeEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkFireCharge, a_Creator, 0.3125, 0.3125) { - SetSpeed(a_Speed); SetGravity(0); } diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h index 5df55bec4..cbfd4beb6 100644 --- a/src/Entities/FireChargeEntity.h +++ b/src/Entities/FireChargeEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cFireChargeEntity) - cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cFireChargeEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/GhastFireballEntity.cpp b/src/Entities/GhastFireballEntity.cpp index 9e4cb387e..b3456f6db 100644 --- a/src/Entities/GhastFireballEntity.cpp +++ b/src/Entities/GhastFireballEntity.cpp @@ -7,10 +7,9 @@ -cGhastFireballEntity::cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkGhastFireball, a_Creator, a_X, a_Y, a_Z, 1, 1) +cGhastFireballEntity::cGhastFireballEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkGhastFireball, a_Creator, 1, 1) { - SetSpeed(a_Speed); SetGravity(0); } diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h index 3ed72d9ef..6c8a20b08 100644 --- a/src/Entities/GhastFireballEntity.h +++ b/src/Entities/GhastFireballEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cGhastFireballEntity) - cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cGhastFireballEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index 3276bc4a0..5cc502548 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -9,8 +9,8 @@ -cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8) +cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, CreateEntityInfo a_Info) + : cEntity(a_Info, a_EntityType, 0.8, 0.8) , m_BlockFace(a_BlockFace) { SetMaxHealth(1); diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h index 1cc0034e1..e071f7bed 100644 --- a/src/Entities/HangingEntity.h +++ b/src/Entities/HangingEntity.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cHangingEntity) - cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); + cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, CreateEntityInfo a_Info); /** Returns the orientation from the hanging entity */ eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index f512324eb..38030c485 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -9,8 +9,8 @@ -cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) - : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z) +cItemFrame::cItemFrame(eBlockFace a_BlockFace, CreateEntityInfo a_Info) + : cHangingEntity(etItemFrame, a_BlockFace, a_Info) , m_Item(E_BLOCK_AIR) , m_Rotation(0) { diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h index a63b78b70..6a375ab3d 100644 --- a/src/Entities/ItemFrame.h +++ b/src/Entities/ItemFrame.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cItemFrame) - cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z); + cItemFrame(eBlockFace a_BlockFace, CreateEntityInfo a_Info); /** Returns the item in the frame */ const cItem & GetItem(void) { return m_Item; } // tolua_export diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index f45e7bb69..e733d9ee1 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -84,18 +84,14 @@ protected: -cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : - super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7), +cMinecart::cMinecart(ePayload a_Payload, CreateEntityInfo a_Info) : + super(a_Info, etMinecart, 0.98, 0.7, 6), m_Payload(a_Payload), m_LastDamage(0), m_DetectorRailPosition(0, 0, 0), m_bIsOnDetectorRail(false) { SetMass(20.f); - SetMaxHealth(6); - SetHealth(6); - SetWidth(1); - SetHeight(0.9); } @@ -1059,8 +1055,8 @@ void cMinecart::Destroyed() //////////////////////////////////////////////////////////////////////////////// // cRideableMinecart: -cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height) : - super(mpNone, a_X, a_Y, a_Z), +cRideableMinecart::cRideableMinecart(CreateEntityInfo a_Info, const cItem & a_Content, int a_Height) : + super(mpNone, a_Info), m_Content(a_Content), m_Height(a_Height) { @@ -1104,8 +1100,8 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player) //////////////////////////////////////////////////////////////////////////////// // cMinecartWithChest: -cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) : - super(mpChest, a_X, a_Y, a_Z), +cMinecartWithChest::cMinecartWithChest(CreateEntityInfo a_Info) : + super(mpChest, a_Info), cEntityWindowOwner(this), m_Contents(ContentsWidth, ContentsHeight) { @@ -1163,8 +1159,8 @@ void cMinecartWithChest::Destroyed() //////////////////////////////////////////////////////////////////////////////// // cMinecartWithFurnace: -cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : - super(mpFurnace, a_X, a_Y, a_Z), +cMinecartWithFurnace::cMinecartWithFurnace(CreateEntityInfo a_Info) : + super(mpFurnace, a_Info), m_FueledTimeLeft(-1), m_IsFueled(false) { @@ -1225,8 +1221,8 @@ void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk) //////////////////////////////////////////////////////////////////////////////// // cMinecartWithTNT: -cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : - super(mpTNT, a_X, a_Y, a_Z) +cMinecartWithTNT::cMinecartWithTNT(CreateEntityInfo a_Info) : + super(mpTNT, a_Info) { } @@ -1239,8 +1235,8 @@ cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : //////////////////////////////////////////////////////////////////////////////// // cMinecartWithHopper: -cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) : - super(mpHopper, a_X, a_Y, a_Z) +cMinecartWithHopper::cMinecartWithHopper(CreateEntityInfo a_Info) : + super(mpHopper, a_Info) { } diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h index 6b6ad36b5..a542d5321 100644 --- a/src/Entities/Minecart.h +++ b/src/Entities/Minecart.h @@ -51,7 +51,7 @@ protected: Vector3i m_DetectorRailPosition; bool m_bIsOnDetectorRail; - cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z); + cMinecart(ePayload a_Payload, CreateEntityInfo a_Info); /** Handles physics on normal rails For each tick, slow down on flat rails, speed up or slow down on ascending/descending rails (depending on direction), and turn on curved rails @@ -93,7 +93,7 @@ class cRideableMinecart : public: CLASS_PROTODEF(cRideableMinecart) - cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height); + cRideableMinecart(CreateEntityInfo a_Info, const cItem & a_Content, int a_Height); const cItem & GetContent(void) const {return m_Content;} int GetBlockHeight(void) const {return m_Height;} @@ -119,7 +119,7 @@ class cMinecartWithChest : public: CLASS_PROTODEF(cMinecartWithChest) - cMinecartWithChest(double a_X, double a_Y, double a_Z); + cMinecartWithChest(CreateEntityInfo a_Info); enum { @@ -167,7 +167,7 @@ class cMinecartWithFurnace : public: CLASS_PROTODEF(cMinecartWithFurnace) - cMinecartWithFurnace(double a_X, double a_Y, double a_Z); + cMinecartWithFurnace(CreateEntityInfo a_Info); // cEntity overrides: virtual void OnRightClicked(cPlayer & a_Player) override; @@ -199,7 +199,7 @@ class cMinecartWithTNT : public: CLASS_PROTODEF(cMinecartWithTNT) - cMinecartWithTNT(double a_X, double a_Y, double a_Z); + cMinecartWithTNT(CreateEntityInfo a_Info); } ; @@ -214,5 +214,5 @@ class cMinecartWithHopper : public: CLASS_PROTODEF(cMinecartWithHopper) - cMinecartWithHopper(double a_X, double a_Y, double a_Z); + cMinecartWithHopper(CreateEntityInfo a_Info); } ; diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index fc8ca3d47..9ae37370b 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -9,9 +9,9 @@ -cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) : - super(a_EntityType, 0, 0, 0, a_Width, a_Height) - , m_EntityEffects(tEffectMap()) +cPawn::cPawn(CreateMonsterInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height) : + super(a_Info.EntityInfo, a_EntityType, a_Width, a_Height, a_Info.MonsterInfo.m_MaxHealth), + m_EntityEffects(tEffectMap()) { } diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h index d50bcd8af..5674d0562 100644 --- a/src/Entities/Pawn.h +++ b/src/Entities/Pawn.h @@ -18,7 +18,7 @@ class cPawn : public: CLASS_PROTODEF(cPawn) - cPawn(eEntityType a_EntityType, double a_Width, double a_Height); + cPawn(CreateMonsterInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height); virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index 87b5bed07..6917e4dad 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -84,17 +84,14 @@ protected: -cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) - : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2) - , m_Timer(0.f) - , m_Item(a_Item) - , m_bCollected(false) - , m_bIsPlayerCreated(IsPlayerCreated) +cPickup::cPickup(CreateEntityInfo a_Info, const cItem & a_Item, bool IsPlayerCreated) + : cEntity(etPickup, a_Info, 0.2, 0.2, 5), + m_DestroyTimer(0), + m_Item(a_Item), + m_bCollected(false), + m_bIsPlayerCreated(IsPlayerCreated) { SetGravity(-10.5f); - SetMaxHealth(5); - SetHealth(5); - SetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); } @@ -112,10 +109,10 @@ void cPickup::SpawnOn(cClientHandle & a_Client) void cPickup::Tick(float a_Dt, cChunk & a_Chunk) { + UNUSED(a_Dt); + super::Tick(a_Dt, a_Chunk); BroadcastMovementUpdate(); // Notify clients of position - - m_Timer += a_Dt; if (!m_bCollected) { @@ -141,13 +138,8 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) ) { m_bCollected = true; - m_Timer = 0; // We have to reset the timer. - m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick. - if (m_Timer > 500.f) - { - Destroy(true); - return; - } + Destroy(); + return; } // Try to combine the pickup with adjacent same-item pickups: @@ -167,22 +159,25 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk) } else { - if (m_Timer > 500.f) // 0.5 second + // Playing collect animation, wait until it's complete + m_DestroyTimer++; + + if (m_DestroyTimer == 10) // Animation lasts around 0.5 seconds { - Destroy(true); + Destroy(); return; } } - if (m_Timer > 1000 * 60 * 5) // 5 minutes + if (GetTicksAlive() >= 20 * 60 * 5) // 5 minutes { - Destroy(true); + Destroy(); return; } if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible! { - Destroy(true); + Destroy(); return; } } @@ -202,7 +197,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) } // Two seconds if player created the pickup (vomiting), half a second if anything else - if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f)) + if (GetTicksAlive() < (m_bIsPlayerCreated ? 40 : 10)) { // LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str()); return false; // Not old enough @@ -236,7 +231,6 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) // All of the pickup has been collected, schedule the pickup for destroying m_bCollected = true; } - m_Timer = 0; return true; } diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h index 4d5250819..4fa430767 100644 --- a/src/Entities/Pickup.h +++ b/src/Entities/Pickup.h @@ -25,7 +25,7 @@ public: CLASS_PROTODEF(cPickup) - cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); + cPickup(CreateEntityInfo a_Info, const cItem & a_Item, bool IsPlayerCreated); cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } @@ -36,12 +36,6 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - /** Returns the number of ticks that this entity has existed */ - int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export - - /** Set the number of ticks that this entity has existed */ - void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export - /** Returns true if the pickup has already been collected */ bool IsCollected(void) const { return m_bCollected; } // tolua_export @@ -50,8 +44,7 @@ public: private: - /** The number of ticks that the entity has existed / timer between collect and destroy; in msec */ - float m_Timer; + int m_DestroyTimer; cItem m_Item; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a0d96e7d..2757c7518 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -226,14 +226,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) bool CanMove = true; if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick? - { - // Apply food exhaustion from movement: - ApplyFoodExhaustionFromMovement(); - + { if (cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this, m_LastPos, GetPosition())) { CanMove = false; - TeleportToCoords(m_LastPos.x, m_LastPos.y, m_LastPos.z); + SetPosition(m_LastPos, true); + } + else + { + // Apply food exhaustion from movement: + ApplyFoodExhaustionFromMovement(); } m_ClientHandle->StreamChunks(); } @@ -1007,17 +1009,16 @@ void cPlayer::Respawn(void) m_FoodSaturationLevel = 5.0; m_FoodExhaustionLevel = 0.0; - // Reset Experience + // Reset experience m_CurrentXp = 0; m_LifetimeTotalXp = 0; - // ToDo: send score to client? How? m_ClientHandle->SendRespawn(GetWorld()->GetDimension(), true); // Extinguish the fire: StopBurning(); - TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z); + SetPosition(GetLastBedPos(), true); SetVisible(true); } @@ -1269,21 +1270,6 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach) -void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) -{ - cEntity::SetPosition(a_PosX, a_PosY, a_PosZ); - m_LastGroundHeight = (float)a_PosY; - m_LastJumpHeight = (float)a_PosY; - m_bIsTeleporting = true; - - m_World->BroadcastTeleportEntity(*this, GetClientHandle()); - m_ClientHandle->SendPlayerMoveLook(); -} - - - - - void cPlayer::SendRotation(double a_YawDegrees, double a_PitchDegrees) { SetYaw(a_YawDegrees); @@ -1349,31 +1335,47 @@ void cPlayer::AddSpeed(const Vector3d & a_Speed) -void cPlayer::SetPosition(const Vector3d & a_Position) +void cPlayer::SetPosition(const Vector3d & a_Position, bool a_Teleport) { super::SetPosition(a_Position); - // Teleport the client - TeleportToCoords(a_Position.x, a_Position.y, a_Position.z); + if (a_Teleport) + { + // Teleport the client + m_LastGroundHeight = (float)a_Position.y; + m_LastJumpHeight = (float)a_Position.y; + m_bIsTeleporting = true; + + m_World->BroadcastTeleportEntity(*this, GetClientHandle()); + m_ClientHandle->SendPlayerMoveLook(); + } } -void cPlayer::AddPosition(const Vector3d & a_Position) +void cPlayer::AddPosition(const Vector3d & a_Position, bool a_Teleport) { super::AddPosition(a_Position); - // Teleport the client - TeleportToCoords(GetPosX(), GetPosY(), GetPosZ()); + if (a_Teleport) + { + // Teleport the client + m_LastGroundHeight = (float)a_Position.y; + m_LastJumpHeight = (float)a_Position.y; + m_bIsTeleporting = true; + + m_World->BroadcastTeleportEntity(*this, GetClientHandle()); + m_ClientHandle->SendPlayerMoveLook(); + } } -void cPlayer::MoveTo( const Vector3d & a_NewPos) +void cPlayer::MoveTo(const Vector3d & a_NewPos) { if ((a_NewPos.y < -990) && (GetPosY() > -100)) { @@ -1396,7 +1398,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos) Vector3d DeltaPos = a_NewPos - GetPosition(); UpdateMovementStats(DeltaPos); - SetPosition( a_NewPos); + SetPosition(a_NewPos, false); SetStance(a_NewPos.y + 1.62); } @@ -2206,7 +2208,7 @@ void cPlayer::Detach() { if (!cBlockInfo::IsSolid(m_World->GetBlock(x, y, z)) && cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z))) { - TeleportToCoords(x, y, z); + cEntity::SetPosition(x, y, z); return; } } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 556a118b5..aaf92b24a 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -134,8 +134,6 @@ public: /** Returns whether the player is climbing (ladders, vines etc.) */ bool IsClimbing(void) const; - virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override; - // tolua_begin /** Sends the "look" packet to the player, forcing them to set their rotation to the specified values. @@ -436,6 +434,12 @@ public: Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */ void LoadRank(void); + /** Sets the speed and sends it to the client, so that they are forced to move so. */ + void SetPosition(const Vector3d & a_Position, bool a_Teleport); + + /** Adds to the speed and sends it to the client, so that they are forced to move so. */ + void AddPosition(const Vector3d & a_Position, bool a_Teleport); + // tolua_end // cEntity overrides: @@ -586,12 +590,6 @@ protected: /** Adds to the speed and sends it to the client, so that they are forced to move so. */ virtual void AddSpeed(const Vector3d & a_Speed) override; - /** Sets the speed and sends it to the client, so that they are forced to move so. */ - virtual void SetPosition(const Vector3d & a_Position) override; - - /** Adds to the speed and sends it to the client, so that they are forced to move so. */ - virtual void AddPosition(const Vector3d & a_Position) override; - void ResolvePermissions(void); void ResolveGroups(void); diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index acc9bd674..de551bb10 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -217,8 +217,8 @@ protected: //////////////////////////////////////////////////////////////////////////////// // cProjectileEntity: -cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) : - super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height), +cProjectileEntity::cProjectileEntity(CreateEntityInfo Info, eKind a_Kind, cEntity * a_Creator, double a_Width, double a_Height) : + super(Info, etProjectile, a_Width, a_Height, 1), m_ProjectileKind(a_Kind), m_CreatorData( ((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1), @@ -227,19 +227,6 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a ), m_IsInGround(false) { -} - - - - - -cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) : - super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height), - m_ProjectileKind(a_Kind), - m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "", a_Creator->GetEquippedWeapon().m_Enchantments), - m_IsInGround(false) -{ - SetSpeed(a_Speed); SetYawFromSpeed(); SetPitchFromSpeed(); } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 990136a32..d05e215fc 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -43,8 +43,7 @@ public: CLASS_PROTODEF(cProjectileEntity) - cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); - cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); + cProjectileEntity(CreateEntityInfo Info, eKind a_Kind, cEntity * a_Creator, double a_Width, double a_Height); static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL); diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index fd1a0179b..5fd15ca11 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -68,16 +68,10 @@ private: //////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntity: -cSplashPotionEntity::cSplashPotionEntity( - cEntity * a_Creator, - double a_X, double a_Y, double a_Z, - const Vector3d & a_Speed, - const cItem & a_Item -) : - super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), +cSplashPotionEntity::cSplashPotionEntity(CreateEntityInfo a_Info, cEntity * a_Creator, const cItem & a_Item) : + super(a_Info, pkSplashPotion, a_Creator, 0.25, 0.25), m_DestroyTimer(-1) { - SetSpeed(a_Speed); m_EntityEffectType = cEntityEffect::GetPotionEffectType(a_Item.m_ItemDamage); m_EntityEffect = cEntityEffect( cEntityEffect::GetPotionEffectDuration(a_Item.m_ItemDamage), diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h index 4afc5f204..c427458c2 100644 --- a/src/Entities/SplashPotionEntity.h +++ b/src/Entities/SplashPotionEntity.h @@ -25,12 +25,7 @@ public: CLASS_PROTODEF(cSplashPotionEntity) - cSplashPotionEntity( - cEntity * a_Creator, - double a_X, double a_Y, double a_Z, - const Vector3d & a_Speed, - const cItem & a_Item - ); + cSplashPotionEntity(CreateEntityInfo a_Info, cEntity * a_Creator, const cItem & a_Item); cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; } diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index 53af446cc..aa9802969 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -8,18 +8,8 @@ -cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) : - super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98), - m_FuseTicks(a_FuseTicks) -{ -} - - - - - -cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) : - super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98), +cTNTEntity::cTNTEntity(CreateEntityInfo a_Info, int a_FuseTicks) : + super(etTNT, a_Info, 0.98, 0.98, 1), m_FuseTicks(a_FuseTicks) { } diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h index 48503cf76..8d29aeb47 100644 --- a/src/Entities/TNTEntity.h +++ b/src/Entities/TNTEntity.h @@ -16,8 +16,7 @@ public: // tolua_end CLASS_PROTODEF(cTNTEntity) - cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80); - cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80); + cTNTEntity(CreateEntityInfo a_Info, int a_FuseTicks = 80); // cEntity overrides: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp index 5ae85bee8..a6ae549ff 100644 --- a/src/Entities/ThrownEggEntity.cpp +++ b/src/Entities/ThrownEggEntity.cpp @@ -7,11 +7,10 @@ -cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), +cThrownEggEntity::cThrownEggEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkEgg, a_Creator, 0.25, 0.25), m_DestroyTimer(-1) { - SetSpeed(a_Speed); } diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h index a0b7d5340..de401d389 100644 --- a/src/Entities/ThrownEggEntity.h +++ b/src/Entities/ThrownEggEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cThrownEggEntity) - cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cThrownEggEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index c7407e6ae..555c10688 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -7,11 +7,10 @@ -cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), +cThrownEnderPearlEntity::cThrownEnderPearlEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkEnderPearl, a_Creator, 0.25, 0.25), m_DestroyTimer(-1) { - SetSpeed(a_Speed); } @@ -64,7 +63,7 @@ void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) virtual bool Item(cPlayer * a_Entity) override { // Teleport the creator here, make them take 5 damage: - a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z); + a_Entity->SetPosition(m_HitPos, true); a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0); return true; } diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h index 436450013..3ff109764 100644 --- a/src/Entities/ThrownEnderPearlEntity.h +++ b/src/Entities/ThrownEnderPearlEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cThrownEnderPearlEntity) - cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cThrownEnderPearlEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp index 496397100..74b7f02e4 100644 --- a/src/Entities/ThrownSnowballEntity.cpp +++ b/src/Entities/ThrownSnowballEntity.cpp @@ -7,11 +7,10 @@ -cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), +cThrownSnowballEntity::cThrownSnowballEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkSnowball, a_Creator, 0.25, 0.25), m_DestroyTimer(-1) { - SetSpeed(a_Speed); } diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h index 8d195ced1..b0c2164bb 100644 --- a/src/Entities/ThrownSnowballEntity.h +++ b/src/Entities/ThrownSnowballEntity.h @@ -23,7 +23,7 @@ public: CLASS_PROTODEF(cThrownSnowballEntity) - cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cThrownSnowballEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp index a7e774bba..453d51342 100644 --- a/src/Entities/WitherSkullEntity.cpp +++ b/src/Entities/WitherSkullEntity.cpp @@ -12,10 +12,9 @@ -cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) : - super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25) +cWitherSkullEntity::cWitherSkullEntity(CreateEntityInfo a_Info, cEntity * a_Creator) : + super(a_Info, pkWitherSkull, a_Creator, 0.25, 0.25) { - SetSpeed(a_Speed); } @@ -41,7 +40,7 @@ void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_H // TODO: Explode // TODO: Apply wither effect to entity and others nearby - Destroy(true); + Destroy(); } diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h index c59acd807..1f007ba87 100644 --- a/src/Entities/WitherSkullEntity.h +++ b/src/Entities/WitherSkullEntity.h @@ -24,7 +24,7 @@ public: CLASS_PROTODEF(cWitherSkullEntity) - cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); + cWitherSkullEntity(CreateEntityInfo a_Info, cEntity * a_Creator); protected: |