summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-05-10 14:15:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-05-10 14:15:13 +0200
commit1cb1347c53c7482883dcc2eb047f8fe798a12481 (patch)
treebe616a3c3b2db083b2f3908220818231778609ef /src/Mobs
parentMerge pull request #1985 from SafwatHalaby/lessPathCalcs (diff)
parentMerge remote-tracking branch 'origin/master' into warnings (diff)
downloadcuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar.gz
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar.bz2
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar.lz
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar.xz
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.tar.zst
cuberite-1cb1347c53c7482883dcc2eb047f8fe798a12481.zip
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Monster.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 3d3fdfb64..f3f8c6b24 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -261,7 +261,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk)
bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
{
- cChunk * Chunk = a_Chunk.GetNeighborChunk(m_FinalDestination.x, m_FinalDestination.z);
+ cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(m_FinalDestination.x), FloorC(m_FinalDestination.z));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
@@ -270,13 +270,13 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
return false;
}
- int RelX = m_FinalDestination.x - Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = m_FinalDestination.z - Chunk->GetPosZ() * cChunkDef::Width;
+ int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
// If destination in the air, go down to the lowest air block.
while (m_FinalDestination.y > 0)
{
- Chunk->GetBlockTypeMeta(RelX, m_FinalDestination.y - 1, RelZ, BlockType, BlockMeta);
+ Chunk->GetBlockTypeMeta(RelX, FloorC(m_FinalDestination.y) - 1, RelZ, BlockType, BlockMeta);
if (cBlockInfo::IsSolid(BlockType))
{
break;
@@ -290,7 +290,7 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
bool InWater = false;
while (m_FinalDestination.y < cChunkDef::Height)
{
- Chunk->GetBlockTypeMeta(RelX, m_FinalDestination.y, RelZ, BlockType, BlockMeta);
+ Chunk->GetBlockTypeMeta(RelX, FloorC(m_FinalDestination.y), RelZ, BlockType, BlockMeta);
if (BlockType == E_BLOCK_STATIONARY_WATER)
{
InWater = true;
@@ -1172,17 +1172,19 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk, bool WouldBurn)
bool cMonster::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
{
- cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(m_NextWayPointPosition.x), FloorC(m_NextWayPointPosition.z));
+ cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(a_Location.x), FloorC(a_Location.z));
if ((Chunk == nullptr) || (!Chunk->IsValid()))
{
return false;
}
- int RelX = FloorC(a_Location.x) - a_Chunk.GetPosX() * cChunkDef::Width;
+
+ int RelX = FloorC(a_Location.x) - Chunk->GetPosX() * cChunkDef::Width;
int RelY = FloorC(a_Location.y);
- int RelZ = FloorC(a_Location.z) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ int RelZ = FloorC(a_Location.z) - Chunk->GetPosZ() * cChunkDef::Width;
+
if (
- (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
- (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
+ (Chunk->GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
+ (Chunk->GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
(GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
GetWorld()->IsWeatherSunnyAt(POSX_TOINT, POSZ_TOINT) // Not raining
)