Avoid pickups to sink into blocks and disappear (#3739)
* Avoid pickups to sink into blocks and disappear
This commit is contained in:
parent
832298e7aa
commit
2b699dc749
@ -1010,6 +1010,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
NextPos.y += 0.5;
|
NextPos.y += 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bHasSentNoSpeed = false; // this unlocks movement sending to client in BroadcastMovementUpdate function
|
||||||
m_bOnGround = true;
|
m_bOnGround = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1915,6 +1916,9 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
|
|||||||
m_bHasSentNoSpeed = false;
|
m_bHasSentNoSpeed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only send movement if speed is not 0 and 'no speed' was sent to client
|
||||||
|
if (!m_bHasSentNoSpeed)
|
||||||
|
{
|
||||||
// TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
|
// TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position
|
||||||
int DiffX = FloorC(GetPosX() * 32.0) - FloorC(m_LastSentPosition.x * 32.0);
|
int DiffX = FloorC(GetPosX() * 32.0) - FloorC(m_LastSentPosition.x * 32.0);
|
||||||
int DiffY = FloorC(GetPosY() * 32.0) - FloorC(m_LastSentPosition.y * 32.0);
|
int DiffY = FloorC(GetPosY() * 32.0) - FloorC(m_LastSentPosition.y * 32.0);
|
||||||
@ -1946,6 +1950,7 @@ void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
|
|||||||
m_bDirtyOrientation = false;
|
m_bDirtyOrientation = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_bDirtyHead)
|
if (m_bDirtyHead)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
virtual bool Item(cEntity * a_Entity) override
|
virtual bool Item(cEntity * a_Entity) override
|
||||||
{
|
{
|
||||||
ASSERT(a_Entity->IsTicking());
|
ASSERT(a_Entity->IsTicking());
|
||||||
if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()))
|
if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()) || !a_Entity->IsOnGround())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -59,6 +59,12 @@ public:
|
|||||||
|
|
||||||
if (Item.m_ItemCount <= 0)
|
if (Item.m_ItemCount <= 0)
|
||||||
{
|
{
|
||||||
|
/* Experimental: show animation pickups getting together */
|
||||||
|
int DiffX = FloorC(m_Pickup->GetPosX() * 32.0) - FloorC(EntityPos.x * 32.0);
|
||||||
|
int DiffY = FloorC(m_Pickup->GetPosY() * 32.0) - FloorC(EntityPos.y * 32.0);
|
||||||
|
int DiffZ = FloorC(m_Pickup->GetPosZ() * 32.0) - FloorC(EntityPos.z * 32.0);
|
||||||
|
a_Entity->GetWorld()->BroadcastEntityRelMove(*a_Entity, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ));
|
||||||
|
/* End of experimental animation */
|
||||||
a_Entity->Destroy();
|
a_Entity->Destroy();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -159,7 +165,7 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to combine the pickup with adjacent same-item pickups:
|
// Try to combine the pickup with adjacent same-item pickups:
|
||||||
if ((m_Item.m_ItemCount < m_Item.GetMaxStackSize())) // Don't combine if already full
|
if ((m_Item.m_ItemCount < m_Item.GetMaxStackSize()) && IsOnGround()) // Don't combine if already full or not on ground
|
||||||
{
|
{
|
||||||
// By using a_Chunk's ForEachEntity() instead of cWorld's, pickups don't combine across chunk boundaries.
|
// By using a_Chunk's ForEachEntity() instead of cWorld's, pickups don't combine across chunk boundaries.
|
||||||
// That is a small price to pay for not having to traverse the entire world for each entity.
|
// That is a small price to pay for not having to traverse the entire world for each entity.
|
||||||
|
Loading…
Reference in New Issue
Block a user