summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-08 15:39:40 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-09-08 15:39:40 +0200
commit9ab5627a393a0b178f13fbba2c39463cfe0675b8 (patch)
tree1f89501893f02a6e711e5a31868a8acdb4ca7de5 /src/Entities
parentd (diff)
parentShutdown connection when disconnect packet sent (#3999) (diff)
downloadcuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.gz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.bz2
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.lz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.xz
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.tar.zst
cuberite-9ab5627a393a0b178f13fbba2c39463cfe0675b8.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/ArrowEntity.cpp6
-rw-r--r--src/Entities/ArrowEntity.h4
-rw-r--r--src/Entities/Boat.cpp4
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/Entity.cpp31
-rw-r--r--src/Entities/Entity.h9
-rw-r--r--src/Entities/ExpBottleEntity.cpp18
-rw-r--r--src/Entities/ExpBottleEntity.h10
-rw-r--r--src/Entities/FireChargeEntity.cpp4
-rw-r--r--src/Entities/FireChargeEntity.h4
-rw-r--r--src/Entities/GhastFireballEntity.cpp4
-rw-r--r--src/Entities/GhastFireballEntity.h4
-rw-r--r--src/Entities/Player.cpp22
-rw-r--r--src/Entities/Player.h18
-rw-r--r--src/Entities/ProjectileEntity.cpp4
-rw-r--r--src/Entities/ProjectileEntity.h4
-rw-r--r--src/Entities/SplashPotionEntity.cpp10
-rw-r--r--src/Entities/SplashPotionEntity.h11
-rw-r--r--src/Entities/TNTEntity.cpp14
-rw-r--r--src/Entities/TNTEntity.h3
-rw-r--r--src/Entities/ThrownEggEntity.cpp6
-rw-r--r--src/Entities/ThrownEggEntity.h6
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp6
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h6
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp4
-rw-r--r--src/Entities/ThrownSnowballEntity.h4
-rw-r--r--src/Entities/WitherSkullEntity.cpp4
-rw-r--r--src/Entities/WitherSkullEntity.h4
28 files changed, 110 insertions, 116 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 6259098d8..2c1a1f005 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -76,7 +76,7 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
-void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cArrowEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Vector3d Hit = a_HitPos;
Hit += GetSpeed().NormalizeCopy() / 100000; // Make arrow sink into block a bit so it lodges (TODO: investigate how to stop them going so far so that they become black clientside)
@@ -93,7 +93,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
if ((m_World->GetBlock(Hit) == E_BLOCK_TNT) && IsOnFire())
{
m_World->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
- m_World->SpawnPrimedTNT(X, Y, Z);
+ m_World->SpawnPrimedTNT(Vector3d(BlockHit));
}
}
@@ -102,7 +102,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
-void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 7ed99b79e..6e4644190 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -100,8 +100,8 @@ protected:
Vector3i m_HitBlockPos;
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ 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 Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index cdb12123c..4021f9ce8 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -13,8 +13,8 @@
-cBoat::cBoat(double a_X, double a_Y, double a_Z, eMaterial a_Material) :
- super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7),
+cBoat::cBoat(Vector3d a_Pos, eMaterial a_Material) :
+ super(etBoat, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.7),
m_LastDamage(0), m_ForwardDirection(0),
m_DamageTaken(0.0f), m_Material(a_Material),
m_RightPaddleUsed(false), m_LeftPaddleUsed(false)
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index a6a99d683..1a00d48c9 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -42,7 +42,7 @@ public:
virtual void Tick(std::chrono::milliseconds 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, eMaterial a_Material);
+ cBoat(Vector3d a_Pos, eMaterial a_Material);
int GetLastDamage(void) const { return m_LastDamage; }
int GetForwardDirection(void) const { return m_ForwardDirection; }
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 9ac8d2e3c..71647200d 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -223,8 +223,6 @@ cChunk * cEntity::GetParentChunk()
void cEntity::Destroy(bool a_ShouldBroadcast)
{
- ASSERT(IsTicking());
- ASSERT(GetParentChunk() != nullptr);
SetIsTicking(false);
// Unleash leashed mobs
@@ -238,19 +236,18 @@ void cEntity::Destroy(bool a_ShouldBroadcast)
m_World->BroadcastDestroyEntity(*this);
}
- cChunk * ParentChunk = GetParentChunk();
- // Destroy the entity after two seconds, to give time for all raw pointers such as m_Target
- // to de-target this entity. This is a temporary solution.
- m_World->ScheduleTask(40, [this, ParentChunk](cWorld & a_World)
+ // Destroy the entity after two seconds, to give time for all cMobPointers to nullify.
+ auto ParentChunkCoords = cChunkDef::BlockToChunk(GetPosition());
+ m_World->ScheduleTask(40, [this, ParentChunkCoords](cWorld & a_World)
{
LOGD("Destroying entity #%i (%s) from chunk (%d, %d)",
this->GetUniqueID(), this->GetClass(),
- ParentChunk->GetPosX(), ParentChunk->GetPosZ()
+ ParentChunkCoords.m_ChunkX, ParentChunkCoords.m_ChunkZ
);
// Make sure that RemoveEntity returned a valid smart pointer
// Also, not storing the returned pointer means automatic destruction
- VERIFY(ParentChunk->RemoveEntity(*this));
+ VERIFY(a_World.RemoveEntity(*this));
});
Destroyed();
}
@@ -1194,6 +1191,13 @@ void cEntity::TickBurning(cChunk & a_Chunk)
// Remember the current burning state:
bool HasBeenBurning = (m_TicksLeftBurning > 0);
+ // Fireproof entities burn out on the next tick
+ if (IsFireproof())
+ {
+ m_TicksLeftBurning = 0;
+ }
+
+ // Fire is extinguished by rain
if (GetWorld()->IsWeatherWetAt(POSX_TOINT, POSZ_TOINT))
{
if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT))
@@ -1577,7 +1581,6 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
{
UNUSED(a_ShouldSendRespawn);
ASSERT(a_World != nullptr);
- ASSERT(IsTicking());
if (GetWorld() == a_World)
{
@@ -1598,6 +1601,9 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Tell others we are gone
GetWorld()->BroadcastDestroyEntity(*this);
+ // Take note of old chunk coords
+ auto OldChunkCoords = cChunkDef::BlockToChunk(GetPosition());
+
// Set position to the new position
SetPosition(a_NewPosition);
@@ -1612,16 +1618,15 @@ bool cEntity::DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d
// Queue add to new world and removal from the old one
cWorld * OldWorld = GetWorld();
- cChunk * ParentChunk = GetParentChunk();
SetWorld(a_World); // Chunks may be streamed before cWorld::AddPlayer() sets the world to the new value
- OldWorld->QueueTask([this, ParentChunk, a_World](cWorld & a_OldWorld)
+ OldWorld->QueueTask([this, OldChunkCoords, a_World](cWorld & a_OldWorld)
{
LOGD("Warping entity #%i (%s) from world \"%s\" to \"%s\". Source chunk: (%d, %d) ",
this->GetUniqueID(), this->GetClass(),
a_OldWorld.GetName().c_str(), a_World->GetName().c_str(),
- ParentChunk->GetPosX(), ParentChunk->GetPosZ()
+ OldChunkCoords.m_ChunkX, OldChunkCoords.m_ChunkZ
);
- a_World->AddEntity(ParentChunk->RemoveEntity(*this));
+ a_World->AddEntity(a_OldWorld.RemoveEntity(*this));
cRoot::Get()->GetPluginManager()->CallHookEntityChangedWorld(*this, a_OldWorld);
});
return true;
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 3a4898757..a6ca390fd 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -217,7 +217,6 @@ public:
int GetChunkZ(void) const { return FloorC(m_Position.z / cChunkDef::Width); }
void SetHeadYaw (double a_HeadYaw);
- void SetHeight (double a_Height);
void SetMass (double a_Mass);
void SetPosX (double a_PosX) { SetPosition({a_PosX, m_Position.y, m_Position.z}); }
void SetPosY (double a_PosY) { SetPosition({m_Position.x, a_PosY, m_Position.z}); }
@@ -232,7 +231,7 @@ public:
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
/** Sets the speed of the entity, measured in m / sec */
- void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
+ void SetSpeed(Vector3d a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX);
@@ -243,8 +242,6 @@ public:
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ);
- void SetWidth (double a_Width);
-
void AddPosX (double a_AddPosX) { AddPosition(a_AddPosX, 0, 0); }
void AddPosY (double a_AddPosY) { AddPosition(0, a_AddPosY, 0); }
void AddPosZ (double a_AddPosZ) { AddPosition(0, 0, a_AddPosZ); }
@@ -300,6 +297,10 @@ public:
// tolua_end
+ void SetHeight(double a_Height);
+
+ void SetWidth(double a_Width);
+
/** Exported in ManualBindings */
const Vector3d & GetPosition(void) const { return m_Position; }
diff --git a/src/Entities/ExpBottleEntity.cpp b/src/Entities/ExpBottleEntity.cpp
index 4072b939b..a9d250118 100644
--- a/src/Entities/ExpBottleEntity.cpp
+++ b/src/Entities/ExpBottleEntity.cpp
@@ -8,7 +8,7 @@
-cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
+cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, Vector3d a_Speed) :
super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
{
SetSpeed(a_Speed);
@@ -18,7 +18,17 @@ cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y,
-void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed) :
+ super(pkExpBottle, a_Creator, a_Pos.x, a_Pos.y, a_Pos.z, 0.25, 0.25)
+{
+ SetSpeed(a_Speed);
+}
+
+
+
+
+
+void cExpBottleEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Break(a_HitPos);
}
@@ -27,7 +37,7 @@ void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
-void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
Break(a_HitPos);
}
@@ -36,7 +46,7 @@ void cExpBottleEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
-void cExpBottleEntity::Break(const Vector3d &a_HitPos)
+void cExpBottleEntity::Break(Vector3d a_HitPos)
{
// Spawn an experience orb with a reward between 3 and 11.
m_World->BroadcastSoundParticleEffect(EffectID::PARTICLE_SPLASH_POTION, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0);
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index ea0c2b5a9..1fcc9b138 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -28,17 +28,19 @@ public:
CLASS_PROTODEF(cExpBottleEntity)
- cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, Vector3d a_Speed);
+
+ cExpBottleEntity(cEntity * a_Creator, Vector3d a_Pos, Vector3d a_Speed);
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity (cEntity & a_EntityHit, Vector3d a_HitPos) override;
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
- void Break(const Vector3d & a_HitPos);
+ void Break(Vector3d a_HitPos);
}; // tolua_export
diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp
index 83c1f3c76..5432f9206 100644
--- a/src/Entities/FireChargeEntity.cpp
+++ b/src/Entities/FireChargeEntity.cpp
@@ -31,7 +31,7 @@ void cFireChargeEntity::Explode(Vector3i a_Block)
-void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cFireChargeEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Destroy();
Explode(a_HitPos.Floor());
@@ -41,7 +41,7 @@ void cFireChargeEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
-void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index e17b25903..2ea64d1e3 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -35,8 +35,8 @@ protected:
void Explode(Vector3i a_Block);
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
} ; // tolua_export
diff --git a/src/Entities/GhastFireballEntity.cpp b/src/Entities/GhastFireballEntity.cpp
index 1adfd1bc0..2dbfbf481 100644
--- a/src/Entities/GhastFireballEntity.cpp
+++ b/src/Entities/GhastFireballEntity.cpp
@@ -28,7 +28,7 @@ void cGhastFireballEntity::Explode(Vector3i a_Block)
-void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cGhastFireballEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Destroy();
Explode(a_HitPos.Floor());
@@ -38,7 +38,7 @@ void cGhastFireballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace
-void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cGhastFireballEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
Destroy();
Explode(a_HitPos.Floor());
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 620efd9e6..bf5b333e2 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -35,8 +35,8 @@ protected:
void Explode(Vector3i a_Block);
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
// TODO: Deflecting the fireballs by arrow- or sword- hits
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 4189841b8..7aef38b93 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2203,7 +2203,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
// Load the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
- cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
+ cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetDataPath(), GetName(), GetUUID().ToLongString(), &m_Stats);
StatSerializer.Load();
LOGD("Player %s was read from file \"%s\", spawning at {%.2f, %.2f, %.2f} in world \"%s\"",
@@ -2301,7 +2301,7 @@ bool cPlayer::SaveToDisk()
// Save the player stats.
// We use the default world name (like bukkit) because stats are shared between dimensions / worlds.
- cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
+ cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetDataPath(), GetName(), GetUUID().ToLongString(), &m_Stats);
if (!StatSerializer.Save())
{
LOGWARNING("Could not save stats for player %s", GetName().c_str());
@@ -2352,23 +2352,6 @@ void cPlayer::UseEquippedItem(int a_Amount)
-void cPlayer::TickBurning(cChunk & a_Chunk)
-{
- // Don't burn in creative or spectator and stop burning in creative if necessary
- if (!IsGameModeCreative() && !IsGameModeSpectator())
- {
- super::TickBurning(a_Chunk);
- }
- else if (IsOnFire())
- {
- m_TicksLeftBurning = 0;
- OnFinishedBurning();
- }
-}
-
-
-
-
void cPlayer::HandleFood(void)
{
@@ -3018,4 +3001,3 @@ float cPlayer::GetPlayerRelativeBlockHardness(BLOCKTYPE a_Block)
// LOGD("blockHardness: %f, digSpeed: %f, canHarvestBlockDivisor: %f\n", blockHardness, digSpeed, canHarvestBlockDivisor);
return (blockHardness < 0) ? 0 : ((digSpeed / blockHardness) / canHarvestBlockDivisor);
}
-
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 5c08151c8..2685622ad 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -195,6 +195,15 @@ public:
/** Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world */
bool IsGameModeSpectator(void) const;
+ /** Returns true if the player is fireproof
+ Stops players burning in creative or spectator modes.
+ */
+ virtual bool IsFireproof() const override
+ {
+ return (m_IsFireproof || IsGameModeCreative() || IsGameModeSpectator());
+
+ }
+
/** Returns true if the player can be targeted by Mobs */
bool CanMobsTarget(void) const;
@@ -331,13 +340,13 @@ public:
/** Returns true if the player is currently in the process of eating the currently equipped item */
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
- /** Returns true if the player is currently flying. */
+ /** Returns true if the player is currently flying */
bool IsFlying(void) const { return m_IsFlying; }
- /** Returns if a player is sleeping in a bed */
+ /** Returns true if a player is sleeping in a bed */
bool IsInBed(void) const { return m_bIsInBed; }
- /** returns true if the player has thrown out a floater. */
+ /** Returns true if the player has thrown out a floater */
bool IsFishing(void) const { return m_IsFishing; }
void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID = cEntity::INVALID_ID) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; }
@@ -719,9 +728,6 @@ protected:
/** Filters out damage for creative mode / friendly fire */
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
- /** Stops players from burning in creative mode */
- virtual void TickBurning(cChunk & a_Chunk) override;
-
/** Called in each tick to handle food-related processing */
void HandleFood(void);
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index c2a1f782d..1017f954a 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -300,7 +300,7 @@ std::unique_ptr<cProjectileEntity> cProjectileEntity::Create(eKind a_Kind, cEnti
-void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cProjectileEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// Set the position based on what face was hit:
SetPosition(a_HitPos);
@@ -320,7 +320,7 @@ void cProjectileEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_
-void cProjectileEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cProjectileEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
UNUSED(a_HitPos);
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index da8c650f5..36f53c841 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -49,10 +49,10 @@ public:
static std::unique_ptr<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 = nullptr);
/** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace);
/** Called by the physics blocktracer when the entity hits another entity */
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos);
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos);
/** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest);
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index af4008e83..8356806b3 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -28,7 +28,7 @@ public:
@param a_HitPos The position where the splash potion has splashed
@param a_EntityEffectType The effect type of the potion
@param a_EntityEffect The effect description */
- cSplashPotionCallback(const Vector3d & a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) :
+ cSplashPotionCallback(Vector3d a_HitPos, cEntityEffect::eType a_EntityEffectType, const cEntityEffect & a_EntityEffect) :
m_HitPos(a_HitPos),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect)
@@ -61,7 +61,7 @@ public:
}
private:
- const Vector3d & m_HitPos;
+ Vector3d m_HitPos;
cEntityEffect::eType m_EntityEffectType;
const cEntityEffect & m_EntityEffect;
};
@@ -96,7 +96,7 @@ cSplashPotionEntity::cSplashPotionEntity(
-void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cSplashPotionEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
Splash(a_HitPos);
m_DestroyTimer = 2;
@@ -106,7 +106,7 @@ void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace
-void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
Splash(a_HitPos);
@@ -117,7 +117,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_
-void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
+void cSplashPotionEntity::Splash(Vector3d a_HitPos)
{
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index baa5da725..bb78bfaeb 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -41,16 +41,17 @@ public:
// tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
- cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
const cItem & GetItem(void) const { return m_Item; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
- void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
// tolua_end
+ cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
+ void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
+
protected:
cEntityEffect::eType m_EntityEffectType;
@@ -60,8 +61,8 @@ protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity (cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
{
if (m_DestroyTimer > 0)
@@ -81,7 +82,7 @@ protected:
/** Splashes the potion, fires its particle effects and sounds
@param a_HitPos The position where the potion will splash */
- void Splash(const Vector3d & a_HitPos);
+ void Splash(Vector3d a_HitPos);
virtual void SpawnOn(cClientHandle & a_Client) override;
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 6784f19f5..26217cfcd 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -8,19 +8,7 @@
-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)
-{
- SetGravity(-16.0f);
- SetAirDrag(0.02f);
-}
-
-
-
-
-
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
+cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
m_FuseTicks(a_FuseTicks)
{
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 5f1faa6b4..25c74ded5 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(Vector3d a_Pos, 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 3131f4841..226f37fb6 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -18,7 +18,7 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y,
-void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownEggEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
TrySpawnChicken(a_HitPos);
@@ -29,7 +29,7 @@ void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_H
-void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
int TotalDamage = 0;
// If entity is an Ender Dragon or Ender Crystal, it is damaged.
@@ -72,7 +72,7 @@ void cThrownEggEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
+void cThrownEggEntity::TrySpawnChicken(Vector3d a_HitPos)
{
auto & Random = GetRandomProvider();
if (Random.RandBool(0.125))
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index f20cd41a1..071b974cb 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -33,12 +33,12 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
- void TrySpawnChicken(const Vector3d & a_HitPos);
+ void TrySpawnChicken(Vector3d a_HitPos);
private:
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index 4b2e2f9ff..4dedffc5b 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -19,7 +19,7 @@ cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X
-void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownEnderPearlEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// TODO: Tweak a_HitPos based on block face.
TeleportCreator(a_HitPos);
@@ -31,7 +31,7 @@ void cThrownEnderPearlEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockF
-void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
int TotalDamage = 0;
// TODO: If entity is Ender Crystal, destroy it
@@ -67,7 +67,7 @@ void cThrownEnderPearlEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Ch
-void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
+void cThrownEnderPearlEntity::TeleportCreator(Vector3d a_HitPos)
{
if (m_CreatorData.m_Name.empty())
{
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 03d54e911..ee618f900 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -33,12 +33,12 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
- void TeleportCreator(const Vector3d & a_HitPos);
+ void TeleportCreator(Vector3d a_HitPos);
private:
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index ef88bfd18..8a6426ca9 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -18,7 +18,7 @@ cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, do
-void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cThrownSnowballEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
m_DestroyTimer = 2;
}
@@ -27,7 +27,7 @@ void cThrownSnowballEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFac
-void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
super::OnHitEntity(a_EntityHit, a_HitPos);
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index d22930f8f..7bed78df3 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -33,8 +33,8 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
private:
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index cbf3d7ae9..a82ea8e7a 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -25,7 +25,7 @@ cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a
-void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
+void cWitherSkullEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
{
// TODO: Explode
// TODO: Apply wither effect to entities nearby
@@ -36,7 +36,7 @@ void cWitherSkullEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a
-void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
+void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
{
// TODO: If entity is Ender Crystal, destroy it
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index 11b6fe3aa..af9b31625 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -33,8 +33,8 @@ public:
protected:
// cProjectileEntity overrides:
- virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos) override;
} ; // tolua_export