parent
b6faeaba18
commit
77b3db7e25
|
@ -297,7 +297,6 @@ void cPlayer::CancelChargingBow(void)
|
||||||
|
|
||||||
void cPlayer::SetTouchGround(bool a_bTouchGround)
|
void cPlayer::SetTouchGround(bool a_bTouchGround)
|
||||||
{
|
{
|
||||||
// If just
|
|
||||||
m_bTouchGround = a_bTouchGround;
|
m_bTouchGround = a_bTouchGround;
|
||||||
|
|
||||||
if (!m_bTouchGround)
|
if (!m_bTouchGround)
|
||||||
|
@ -307,12 +306,11 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
|
||||||
m_LastJumpHeight = (float)GetPosY();
|
m_LastJumpHeight = (float)GetPosY();
|
||||||
}
|
}
|
||||||
cWorld * World = GetWorld();
|
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)
|
if (BlockType != E_BLOCK_AIR)
|
||||||
{
|
{
|
||||||
// LOGD("TouchGround set to true by server");
|
|
||||||
m_bTouchGround = true;
|
m_bTouchGround = true;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -320,21 +318,20 @@ void cPlayer::SetTouchGround(bool a_bTouchGround)
|
||||||
(BlockType == E_BLOCK_STATIONARY_WATER) ||
|
(BlockType == E_BLOCK_STATIONARY_WATER) ||
|
||||||
(BlockType == E_BLOCK_LADDER) ||
|
(BlockType == E_BLOCK_LADDER) ||
|
||||||
(BlockType == E_BLOCK_VINES)
|
(BlockType == E_BLOCK_VINES)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// LOGD("Water / Ladder / Torch");
|
|
||||||
m_LastGroundHeight = (float)GetPosY();
|
m_LastGroundHeight = (float)GetPosY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (m_bTouchGround)
|
|
||||||
{
|
{
|
||||||
float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
|
float Dist = (float)(m_LastGroundHeight - floor(GetPosY()));
|
||||||
int Damage = (int)(Dist - 3.f);
|
int Damage = (int)(Dist - 3.f);
|
||||||
if(m_LastJumpHeight > m_LastGroundHeight) Damage++;
|
if (m_LastJumpHeight > m_LastGroundHeight) Damage++;
|
||||||
m_LastJumpHeight = (float)GetPosY();
|
m_LastJumpHeight = (float)GetPosY();
|
||||||
if (Damage > 0)
|
|
||||||
|
if ((Damage > 0) && (!IsGameModeCreative()))
|
||||||
{
|
{
|
||||||
TakeDamage(dtFalling, NULL, Damage, Damage, 0);
|
TakeDamage(dtFalling, NULL, Damage, Damage, 0);
|
||||||
}
|
}
|
||||||
|
@ -1416,11 +1413,11 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
|
||||||
|
|
||||||
void cPlayer::UseEquippedItem(void)
|
void cPlayer::UseEquippedItem(void)
|
||||||
{
|
{
|
||||||
if (GetGameMode() == gmCreative) // No damage in creative
|
if (IsGameModeCreative()) // No damage in creative
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetInventory().DamageEquippedItem();
|
GetInventory().DamageEquippedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ short cItem::GetMaxDamage(void) const
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
|
case E_ITEM_BOW: return 384;
|
||||||
case E_ITEM_DIAMOND_AXE: return 1563;
|
case E_ITEM_DIAMOND_AXE: return 1563;
|
||||||
case E_ITEM_DIAMOND_HOE: return 1563;
|
case E_ITEM_DIAMOND_HOE: return 1563;
|
||||||
case E_ITEM_DIAMOND_PICKAXE: return 1563;
|
case E_ITEM_DIAMOND_PICKAXE: return 1563;
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
|
a_Player->GetWorld()->BroadcastSpawnEntity(*Arrow);
|
||||||
|
a_Player->UseEquippedItem();
|
||||||
}
|
}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,15 @@ public:
|
||||||
|
|
||||||
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||||
{
|
{
|
||||||
|
if (!a_Player->IsGameModeCreative())
|
||||||
|
{
|
||||||
|
a_Player->GetInventory().RemoveOneEquippedItem();
|
||||||
|
}
|
||||||
|
|
||||||
Vector3d Pos = a_Player->GetThrowStartPos();
|
Vector3d Pos = a_Player->GetThrowStartPos();
|
||||||
Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
|
Vector3d Speed = a_Player->GetLookVector() * m_SpeedCoeff;
|
||||||
a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &Speed);
|
a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &Speed);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue