summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/DispenserEntity.cpp2
-rw-r--r--src/BlockEntities/HopperEntity.cpp6
-rw-r--r--src/BlockEntities/MobSpawnerEntity.cpp36
3 files changed, 22 insertions, 22 deletions
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index 9d8267c38..6cb63b495 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -28,7 +28,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
Vector3i dispRelCoord(GetRelPos());
auto meta = a_Chunk.GetMeta(dispRelCoord);
AddDropSpenserDir(dispRelCoord, meta);
- auto dispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(dispRelCoord.x, dispRelCoord.z);
+ auto dispChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(dispRelCoord);
if (dispChunk == nullptr)
{
// Would dispense into / interact with a non-loaded chunk, ignore the tick
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index a0705e996..e85cfb952 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -299,7 +299,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Convert coords to relative:
auto relCoord = a_Chunk.AbsoluteToRelative(out.second);
- auto destChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relCoord.x, relCoord.z);
+ auto destChunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relCoord);
if (destChunk == nullptr)
{
// The destination chunk has been unloaded, don't tick
@@ -379,7 +379,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
for (const auto & ofs: neighborOfs)
{
auto neighborRelCoord = ofs.addedXZ(m_RelX, m_RelZ);
- auto neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(neighborRelCoord.x, neighborRelCoord.z);
+ auto neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(neighborRelCoord);
if (neighbor == nullptr)
{
continue;
@@ -543,7 +543,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, Vector3i a_Coords)
for (const auto & ofs: neighborOfs)
{
auto otherHalfRelCoord = relCoord + ofs;
- auto neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(otherHalfRelCoord.x, otherHalfRelCoord.z);
+ auto neighbor = a_Chunk.GetRelNeighborChunkAdjustCoords(otherHalfRelCoord);
if (neighbor == nullptr)
{
continue;
diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp
index 85bdd7ecf..76b86f73a 100644
--- a/src/BlockEntities/MobSpawnerEntity.cpp
+++ b/src/BlockEntities/MobSpawnerEntity.cpp
@@ -151,36 +151,36 @@ void cMobSpawnerEntity::SpawnEntity(void)
break;
}
- int RelX = m_RelX + static_cast<int>((Random.RandReal<double>() - Random.RandReal<double>()) * 4.0);
- int RelY = m_Pos.y + Random.RandInt(-1, 1);
- int RelZ = m_RelZ + static_cast<int>((Random.RandReal<double>() - Random.RandReal<double>()) * 4.0);
-
- cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelX, RelZ);
- if ((Chunk == nullptr) || !Chunk->IsValid())
+ Vector3i spawnRelPos(GetRelPos());
+ spawnRelPos += Vector3i(
+ static_cast<int>((Random.RandReal<double>() - Random.RandReal<double>()) * 4.0),
+ Random.RandInt(-1, 1),
+ static_cast<int>((Random.RandReal<double>() - Random.RandReal<double>()) * 4.0)
+ );
+
+ auto chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(spawnRelPos);
+ if ((chunk == nullptr) || !chunk->IsValid())
{
continue;
}
- EMCSBiome Biome = Chunk->GetBiomeAt(RelX, RelZ);
+ EMCSBiome Biome = chunk->GetBiomeAt(spawnRelPos.x, spawnRelPos.z);
- if (cMobSpawner::CanSpawnHere(Chunk, RelX, RelY, RelZ, MobType, Biome))
+ if (cMobSpawner::CanSpawnHere(chunk, spawnRelPos, MobType, Biome))
{
- double PosX = Chunk->GetPosX() * cChunkDef::Width + RelX;
- double PosZ = Chunk->GetPosZ() * cChunkDef::Width + RelZ;
-
- auto Monster = cMonster::NewMonsterFromType(MobType);
- if (Monster == nullptr)
+ auto absPos = chunk->RelativeToAbsolute(spawnRelPos);
+ auto monster = cMonster::NewMonsterFromType(MobType);
+ if (monster == nullptr)
{
continue;
}
-
- Monster->SetPosition(PosX, RelY, PosZ);
- Monster->SetYaw(Random.RandReal(360.0f));
- if (Chunk->GetWorld()->SpawnMobFinalize(std::move(Monster)) != cEntity::INVALID_ID)
+ monster->SetPosition(absPos);
+ monster->SetYaw(Random.RandReal(360.0f));
+ if (chunk->GetWorld()->SpawnMobFinalize(std::move(monster)) != cEntity::INVALID_ID)
{
HaveSpawnedEntity = true;
m_World->BroadcastSoundParticleEffect(
EffectID::PARTICLE_MOBSPAWN,
- Vector3d(PosX, RelY, PosZ).Floor(),
+ absPos,
0
);
NearbyEntities++;