summaryrefslogtreecommitdiffstats
path: root/src/Mobs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs')
-rw-r--r--src/Mobs/Monster.cpp18
-rw-r--r--src/Mobs/Sheep.cpp8
-rw-r--r--src/Mobs/Villager.cpp8
3 files changed, 17 insertions, 17 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 237c50524..09c0974a0 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -541,26 +541,26 @@ void cMonster::HandleFalling()
int cMonster::FindFirstNonAirBlockPosition(double a_PosX, double a_PosZ)
{
- int PosY = POSY_TOINT;
- PosY = Clamp(PosY, 0, cChunkDef::Height);
+ auto Position = GetPosition().Floor();
+ Position.y = Clamp(Position.y, 0, cChunkDef::Height);
- if (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))))
+ if (!cBlockInfo::IsSolid(m_World->GetBlock(Position)))
{
- while (!cBlockInfo::IsSolid(m_World->GetBlock(FloorC(a_PosX), PosY, FloorC(a_PosZ))) && (PosY > 0))
+ while (!cBlockInfo::IsSolid(m_World->GetBlock(Position)) && (Position.y > 0))
{
- PosY--;
+ Position.y--;
}
- return PosY + 1;
+ return Position.y + 1;
}
else
{
- while ((PosY < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(static_cast<int>(floor(a_PosX)), PosY, static_cast<int>(floor(a_PosZ)))))
+ while ((Position.y < cChunkDef::Height) && cBlockInfo::IsSolid(m_World->GetBlock(Position)))
{
- PosY++;
+ Position.y++;
}
- return PosY;
+ return Position.y;
}
}
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index e208420db..0a3f68e96 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -113,11 +113,11 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (m_TimeToStopEating == 0)
{
- if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
+ if (m_World->GetBlock({ PosX, PosY, PosZ }) == E_BLOCK_GRASS) // Make sure grass hasn't been destroyed in the meantime
{
// The sheep ate the grass so we change it to dirt
- m_World->SetBlock(PosX, PosY, PosZ, E_BLOCK_DIRT, 0);
- GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, {PosX, PosY, PosZ}, E_BLOCK_GRASS);
+ m_World->SetBlock({ PosX, PosY, PosZ }, E_BLOCK_DIRT, 0);
+ GetWorld()->BroadcastSoundParticleEffect(EffectID::PARTICLE_BLOCK_BREAK, { PosX, PosY, PosZ }, E_BLOCK_GRASS);
m_IsSheared = false;
m_World->BroadcastEntityMetadata(*this);
}
@@ -127,7 +127,7 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (GetRandomProvider().RandBool(1.0 / 600.0))
{
- if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS)
+ if (m_World->GetBlock({ PosX, PosY, PosZ }) == E_BLOCK_GRASS)
{
m_World->BroadcastEntityStatus(*this, esSheepEating);
m_TimeToStopEating = 40;
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 2290d120f..1dc302aec 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -186,8 +186,8 @@ void cVillager::HandleFarmerTryHarvestCrops()
if (!m_PathfinderActivated && (GetPosition() - m_CropsPos).Length() < 2)
{
// Check if the blocks didn't change while the villager was walking to the coordinates.
- BLOCKTYPE CropBlock = m_World->GetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z);
- if (IsBlockFarmable(CropBlock) && m_World->GetBlockMeta(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z) == 0x7)
+ BLOCKTYPE CropBlock = m_World->GetBlock(m_CropsPos);
+ if (IsBlockFarmable(CropBlock) && m_World->GetBlockMeta(m_CropsPos) == 0x7)
{
m_World->DropBlockAsPickups(m_CropsPos, this, nullptr);
m_ActionCountDown = 20;
@@ -202,9 +202,9 @@ void cVillager::HandleFarmerTryHarvestCrops()
void cVillager::HandleFarmerPlaceCrops()
{
// Check if there is still farmland at the spot where the crops were.
- if (m_World->GetBlock(m_CropsPos.x, m_CropsPos.y - 1, m_CropsPos.z) == E_BLOCK_FARMLAND)
+ if (m_World->GetBlock(m_CropsPos.addedY(-1)) == E_BLOCK_FARMLAND)
{
- m_World->SetBlock(m_CropsPos.x, m_CropsPos.y, m_CropsPos.z, E_BLOCK_CROPS, 0);
+ m_World->SetBlock(m_CropsPos, E_BLOCK_CROPS, 0);
}
}