1
0
Fork 0

SetSwimState now takes into account head height

This affects m_IsSubmerged and IsSubmerged() for entities of all
types.

Also prevent squids from suffocating in water.
This commit is contained in:
Alexander Harkness 2017-08-29 21:29:06 +01:00 committed by Alexander Harkness
parent 765db880f9
commit 700bbdabf5
2 changed files with 3 additions and 3 deletions

View File

@ -1666,7 +1666,8 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
m_IsSwimming = IsBlockWater(BlockIn);
// Check if the player is submerged:
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, RelY + 1, RelZ, BlockIn));
int HeadHeight = CeilC(GetPosY() + GetHeight()) - 1;
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, HeadHeight, RelZ, BlockIn));
m_IsSubmerged = IsBlockWater(BlockIn);
}
@ -1698,7 +1699,7 @@ void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
void cEntity::HandleAir(void)
{
// Ref.: https://minecraft.gamepedia.com/Chunk_format
// See if the entity is /submerged/ water (block above is water)
// See if the entity is /submerged/ water (head is in water)
// Get the type of block the entity is standing in:
int RespirationLevel = static_cast<int>(GetEquippedHelmet().m_Enchantments.GetLevel(cEnchantments::enchRespiration));

View File

@ -23,7 +23,6 @@ public:
// Squids do not drown (or float)
virtual void HandleAir(void) override {}
virtual void SetSwimState(cChunk & a_Chunk) override {}
} ;