Merge pull request #3148 from LogicParrot/pathFinderFix
Fix issues below y = 0
This commit is contained in:
commit
931ee84685
@ -878,6 +878,12 @@ void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
m_InvulnerableTicks--;
|
m_InvulnerableTicks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((GetPosY() < 0) && (!IsPlayer()))
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_AttachedTo != nullptr)
|
if (m_AttachedTo != nullptr)
|
||||||
{
|
{
|
||||||
SetPosition(m_AttachedTo->GetPosition());
|
SetPosition(m_AttachedTo->GetPosition());
|
||||||
|
@ -182,12 +182,6 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
Destroy(true);
|
Destroy(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible!
|
|
||||||
{
|
|
||||||
Destroy(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,10 +667,14 @@ void cMonster::InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
|||||||
NIBBLETYPE BlockMeta;
|
NIBBLETYPE BlockMeta;
|
||||||
int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width;
|
int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width;
|
||||||
int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width;
|
int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width;
|
||||||
Chunk->GetBlockTypeMeta(RelX, static_cast<int>(Destination.y) - 1, RelZ, BlockType, BlockMeta);
|
int YBelowUs = static_cast<int>(Destination.y) - 1;
|
||||||
if (BlockType != E_BLOCK_STATIONARY_WATER) // Idle mobs shouldn't enter water on purpose
|
if (YBelowUs >= 0)
|
||||||
{
|
{
|
||||||
MoveToPosition(Destination);
|
Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
|
||||||
|
if (BlockType != E_BLOCK_STATIONARY_WATER) // Idle mobs shouldn't enter water on purpose
|
||||||
|
{
|
||||||
|
MoveToPosition(Destination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,13 @@ bool cPathFinder::EnsureProperPoint(Vector3d & a_Vector, cChunk & a_Chunk)
|
|||||||
// If destination in the air, first try to go 1 block north, or east, or west.
|
// If destination in the air, first try to go 1 block north, or east, or west.
|
||||||
// This fixes the player leaning issue.
|
// This fixes the player leaning issue.
|
||||||
// If that failed, we instead go down to the lowest air block.
|
// If that failed, we instead go down to the lowest air block.
|
||||||
Chunk->GetBlockTypeMeta(RelX, FloorC(a_Vector.y) - 1, RelZ, BlockType, BlockMeta);
|
int YBelowUs = FloorC(a_Vector.y) - 1;
|
||||||
|
if (YBelowUs < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
|
||||||
if (!(IsWaterOrSolid(BlockType)))
|
if (!(IsWaterOrSolid(BlockType)))
|
||||||
{
|
{
|
||||||
bool InTheAir = true;
|
bool InTheAir = true;
|
||||||
@ -216,7 +222,7 @@ bool cPathFinder::EnsureProperPoint(Vector3d & a_Vector, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
RelX = FloorC(a_Vector.x+x) - Chunk->GetPosX() * cChunkDef::Width;
|
RelX = FloorC(a_Vector.x+x) - Chunk->GetPosX() * cChunkDef::Width;
|
||||||
RelZ = FloorC(a_Vector.z+z) - Chunk->GetPosZ() * cChunkDef::Width;
|
RelZ = FloorC(a_Vector.z+z) - Chunk->GetPosZ() * cChunkDef::Width;
|
||||||
Chunk->GetBlockTypeMeta(RelX, FloorC(a_Vector.y) - 1, RelZ, BlockType, BlockMeta);
|
Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
|
||||||
if (IsWaterOrSolid((BlockType)))
|
if (IsWaterOrSolid((BlockType)))
|
||||||
{
|
{
|
||||||
a_Vector.x += x;
|
a_Vector.x += x;
|
||||||
|
Loading…
Reference in New Issue
Block a user