summaryrefslogtreecommitdiffstats
path: root/source/Entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Entities/Entity.cpp4
-rw-r--r--source/Entities/Entity.h6
-rw-r--r--source/Entities/Player.cpp19
-rw-r--r--source/Entities/Player.h4
-rw-r--r--source/Entities/ProjectileEntity.cpp13
5 files changed, 29 insertions, 17 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index d465c75bd..3bea7bc01 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -1178,9 +1178,9 @@ void cEntity::SetMass(double a_Mass)
-void cEntity::SetRotation(double a_Rotation)
+void cEntity::SetYaw(double a_Yaw)
{
- m_Rot.x = a_Rotation;
+ m_Rot.x = a_Yaw;
m_bDirtyOrientation = true;
WrapRotation();
}
diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h
index c6b70a7fc..dafda7826 100644
--- a/source/Entities/Entity.h
+++ b/source/Entities/Entity.h
@@ -151,7 +151,8 @@ public:
double GetPosY (void) const { return m_Pos.y; }
double GetPosZ (void) const { return m_Pos.z; }
const Vector3d & GetRot (void) const { return m_Rot; }
- double GetRotation (void) const { return m_Rot.x; }
+ double GetRotation (void) const { return m_Rot.x; } // OBSOLETE, use GetYaw() instead
+ double GetYaw (void) const { return m_Rot.x; }
double GetPitch (void) const { return m_Rot.y; }
double GetRoll (void) const { return m_Rot.z; }
Vector3d GetLookVector(void) const;
@@ -173,7 +174,8 @@ public:
void SetPosition(double a_PosX, double a_PosY, double a_PosZ);
void SetPosition(const Vector3d & a_Pos) { SetPosition(a_Pos.x, a_Pos.y, a_Pos.z); }
void SetRot (const Vector3f & a_Rot);
- void SetRotation(double a_Rotation);
+ void SetRotation(double a_Rotation) { SetYaw(a_Rotation); } // OBSOLETE, use SetYaw() instead
+ void SetYaw (double a_Yaw);
void SetPitch (double a_Pitch);
void SetRoll (double a_Roll);
void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index d94bc944c..2e4199629 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -297,7 +297,6 @@ void cPlayer::CancelChargingBow(void)
void cPlayer::SetTouchGround(bool a_bTouchGround)
{
- // If just
m_bTouchGround = a_bTouchGround;
if (!m_bTouchGround)
@@ -307,12 +306,11 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
m_LastJumpHeight = (float)GetPosY();
}
cWorld * World = GetWorld();
- if ((GetPosY() >= 0) && (GetPosY() < 256))
+ if ((GetPosY() >= 0) && (GetPosY() < cChunkDef::Height))
{
- BLOCKTYPE BlockType = World->GetBlock( float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()) );
+ BLOCKTYPE BlockType = World->GetBlock(float2int(GetPosX()), float2int(GetPosY()), float2int(GetPosZ()));
if (BlockType != E_BLOCK_AIR)
{
- // LOGD("TouchGround set to true by server");
m_bTouchGround = true;
}
if (
@@ -322,19 +320,18 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
(BlockType == E_BLOCK_VINES)
)
{
- // LOGD("Water / Ladder / Torch");
m_LastGroundHeight = (float)GetPosY();
}
}
}
-
- if (m_bTouchGround)
+ else
{
float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
int Damage = (int)(Dist - 3.f);
- if(m_LastJumpHeight > m_LastGroundHeight) Damage++;
+ if (m_LastJumpHeight > m_LastGroundHeight) Damage++;
m_LastJumpHeight = (float)GetPosY();
- if (Damage > 0)
+
+ if ((Damage > 0) && (!IsGameModeCreative()))
{
TakeDamage(dtFalling, NULL, Damage, Damage, 0);
}
@@ -1416,11 +1413,11 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
void cPlayer::UseEquippedItem(void)
{
- if (GetGameMode() == gmCreative) // No damage in creative
+ if (IsGameModeCreative()) // No damage in creative
{
return;
}
-
+
GetInventory().DamageEquippedItem();
}
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index 449a63231..01efa3681 100644
--- a/source/Entities/Player.h
+++ b/source/Entities/Player.h
@@ -4,6 +4,7 @@
#include "Pawn.h"
#include "../Inventory.h"
#include "../Defines.h"
+#include "../World.h"
@@ -99,6 +100,9 @@ public:
/// Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable
eGameMode GetGameMode(void) const { return m_GameMode; }
+ /// Returns the current effective gamemode (inherited gamemode is resolved before returning)
+ eGameMode GetEffectiveGameMode(void) const { return (m_GameMode == gmNotSet) ? m_World->GetGameMode() : m_GameMode; }
+
/** Sets the gamemode for the player.
The gamemode may be gmNotSet, in that case the player inherits the world's gamemode.
Updates the gamemode on the client (sends the packet)
diff --git a/source/Entities/ProjectileEntity.cpp b/source/Entities/ProjectileEntity.cpp
index 4c8e680d0..1d5532718 100644
--- a/source/Entities/ProjectileEntity.cpp
+++ b/source/Entities/ProjectileEntity.cpp
@@ -474,8 +474,17 @@ cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y,
void cThrownEggEntity::OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace)
{
- // TODO: Random-spawn a chicken or four
-
+ if (m_World->GetTickRandomNumber(7) == 1)
+ {
+ m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
+ }
+ else if (m_World->GetTickRandomNumber(32) == 1)
+ {
+ m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
+ m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
+ m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
+ m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
+ }
Destroy();
}