summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simulator')
-rw-r--r--src/Simulator/FireSimulator.cpp12
-rw-r--r--src/Simulator/FloodyFluidSimulator.cpp30
-rw-r--r--src/Simulator/SandSimulator.cpp4
-rw-r--r--src/Simulator/VaporizeFluidSimulator.cpp11
4 files changed, 23 insertions, 34 deletions
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 9a00d00a8..7862ed335 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -129,7 +129,7 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
// Randomly burn out the fire if it is raining:
if (!BurnsForever && Raining && GetRandomProvider().RandBool(CHANCE_BASE_RAIN_EXTINGUISH + (BlockMeta * CHANCE_AGE_M_RAIN_EXTINGUISH)))
{
- a_Chunk->SetBlock(x, y, z, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({x, y, z}, E_BLOCK_AIR, 0);
itr = Data.erase(itr);
continue;
}
@@ -157,7 +157,7 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
FIRE_FLOG("FS: Fire at {0} burnt out, removing the fire block",
a_Chunk->PositionToWorldPosition({itr->x, itr->y, itr->z})
);
- a_Chunk->SetBlock(x, y, z, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({x, y, z}, E_BLOCK_AIR, 0);
RemoveFuelNeighbors(a_Chunk, x, y, z);
itr = Data.erase(itr);
continue;
@@ -314,7 +314,7 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
// Checked through everything, nothing was flammable
// If block below isn't solid, we can't have fire, it would be a non-fueled fire
// SetBlock just to make sure fire doesn't spawn
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, E_BLOCK_AIR, 0);
return 0;
}
return static_cast<int>(m_BurnStepTimeNonfuel);
@@ -403,18 +403,18 @@ void cFireSimulator::RemoveFuelNeighbors(cChunk * a_Chunk, int a_RelX, int a_Rel
if (BlockType == E_BLOCK_TNT)
{
m_World.SpawnPrimedTNT({static_cast<double>(AbsX), static_cast<double>(Y), static_cast<double>(AbsZ)}, 0);
- Neighbour->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
+ Neighbour->SetBlock({X, Y, Z}, E_BLOCK_AIR, 0);
return;
}
bool ShouldReplaceFuel = (GetRandomProvider().RandBool(m_ReplaceFuelChance * (1.0 / MAX_CHANCE_REPLACE_FUEL)));
if (ShouldReplaceFuel && !cRoot::Get()->GetPluginManager()->CallHookBlockSpread(m_World, AbsX, Y, AbsZ, ssFireSpread))
{
- Neighbour->SetBlock(X, Y, Z, E_BLOCK_FIRE, 0);
+ Neighbour->SetBlock({X, Y, Z}, E_BLOCK_FIRE, 0);
}
else
{
- Neighbour->SetBlock(X, Y, Z, E_BLOCK_AIR, 0);
+ Neighbour->SetBlock({X, Y, Z}, E_BLOCK_AIR, 0);
}
} // for i - Coords[]
}
diff --git a/src/Simulator/FloodyFluidSimulator.cpp b/src/Simulator/FloodyFluidSimulator.cpp
index 7066dc016..f00dd3bfd 100644
--- a/src/Simulator/FloodyFluidSimulator.cpp
+++ b/src/Simulator/FloodyFluidSimulator.cpp
@@ -193,7 +193,7 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
if (a_MyMeta >= 8)
{
FLUID_FLOG(" Not fed and downwards, turning into non-downwards meta {0}", m_Falloff);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, m_Falloff);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, m_StationaryFluidBlock, m_Falloff);
}
else
{
@@ -201,12 +201,12 @@ bool cFloodyFluidSimulator::CheckTributaries(cChunk * a_Chunk, int a_RelX, int a
if (a_MyMeta < 8)
{
FLUID_FLOG(" Not fed, decreasing from {0} to {1}", a_MyMeta - m_Falloff, a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_StationaryFluidBlock, a_MyMeta);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, m_StationaryFluidBlock, a_MyMeta);
}
else
{
FLUID_FLOG(" Not fed, meta {0}, erasing altogether", a_MyMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, E_BLOCK_AIR, 0);
}
}
return true;
@@ -254,7 +254,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
FLUID_FLOG(" Lava flowing into water, turning water at rel {0} into {1}",
Vector3i{a_RelX, a_RelY, a_RelZ}, ItemTypeToString(NewBlock)
);
- a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+ a_NearChunk->SetBlock({a_RelX, a_RelY, a_RelZ}, NewBlock, 0);
m_World.BroadcastSoundEffect(
"block.lava.extinguish",
@@ -274,7 +274,7 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
FLUID_FLOG(" Water flowing into lava, turning lava at rel {0} into {1}",
Vector3i{a_RelX, a_RelY, a_RelZ}, ItemTypeToString(NewBlock)
);
- a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, NewBlock, 0);
+ a_NearChunk->SetBlock({a_RelX, a_RelY, a_RelZ}, NewBlock, 0);
m_World.BroadcastSoundEffect(
"block.lava.extinguish",
@@ -302,23 +302,13 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
cBlockHandler * Handler = BlockHandler(BlockType);
if (Handler->DoesDropOnUnsuitable())
{
- cChunkInterface ChunkInterface(m_World.GetChunkMap());
- cBlockInServerPluginInterface PluginInterface(m_World);
- Handler->DropBlock(
- ChunkInterface,
- m_World,
- PluginInterface,
- nullptr,
- BlockX,
- a_RelY,
- BlockZ
- );
+ m_World.DropBlockAsPickups({BlockX, a_RelY, BlockZ}, nullptr, nullptr);
}
} // if (CanWashAway)
// Spread:
FLUID_FLOG(" Spreading to {0} with meta {1}", Vector3i{BlockX, a_RelY, BlockZ}, a_NewMeta);
- a_NearChunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
+ a_NearChunk->SetBlock({a_RelX, a_RelY, a_RelZ}, m_FluidBlock, a_NewMeta);
m_World.GetSimulatorManager()->WakeUp({BlockX, a_RelY, BlockZ}, a_NearChunk);
HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
@@ -362,7 +352,7 @@ bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX
{
// Found enough, turn into a source and bail out
// FLUID_FLOG(" Found enough neighbor sources, turning into a source");
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, m_FluidBlock, 0);
return true;
}
}
@@ -411,13 +401,13 @@ bool cFloodyFluidSimulator::HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY
if (a_Meta == 0)
{
// Source lava block
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, E_BLOCK_OBSIDIAN, 0);
return true;
}
// Ignore last lava level
else if (a_Meta <= 4)
{
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, E_BLOCK_COBBLESTONE, 0);
return true;
}
}
diff --git a/src/Simulator/SandSimulator.cpp b/src/Simulator/SandSimulator.cpp
index a75ea2d11..5f0595d48 100644
--- a/src/Simulator/SandSimulator.cpp
+++ b/src/Simulator/SandSimulator.cpp
@@ -67,7 +67,7 @@ void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
{
continue;
}
- a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({itr->x, itr->y, itr->z}, E_BLOCK_AIR, 0);
}
}
m_TotalBlocks -= static_cast<int>(ChunkData.size());
@@ -302,7 +302,7 @@ void cSandSimulator::DoInstantFall(cChunk * a_Chunk, int a_RelX, int a_RelY, int
BLOCKTYPE FallingBlockType;
NIBBLETYPE FallingBlockMeta;
a_Chunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, FallingBlockType, FallingBlockMeta);
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock({a_RelX, a_RelY, a_RelZ}, E_BLOCK_AIR, 0);
// Search for a place to put it:
for (int y = a_RelY - 1; y >= 0; y--)
diff --git a/src/Simulator/VaporizeFluidSimulator.cpp b/src/Simulator/VaporizeFluidSimulator.cpp
index 32a55794d..441c0bb6c 100644
--- a/src/Simulator/VaporizeFluidSimulator.cpp
+++ b/src/Simulator/VaporizeFluidSimulator.cpp
@@ -28,15 +28,14 @@ void cVaporizeFluidSimulator::AddBlock(Vector3i a_Block, cChunk * a_Chunk)
{
return;
}
- int RelX = a_Block.x - a_Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = a_Block.z - a_Chunk->GetPosZ() * cChunkDef::Width;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(RelX, a_Block.y, RelZ);
+ auto relPos = cChunkDef::AbsoluteToRelative(a_Block);
+ auto blockType = a_Chunk->GetBlock(relPos);
if (
- (BlockType == m_FluidBlock) ||
- (BlockType == m_StationaryFluidBlock)
+ (blockType == m_FluidBlock) ||
+ (blockType == m_StationaryFluidBlock)
)
{
- a_Chunk->SetBlock(RelX, a_Block.y, RelZ, E_BLOCK_AIR, 0);
+ a_Chunk->SetBlock(relPos, E_BLOCK_AIR, 0);
World::GetBroadcastInterface(m_World).BroadcastSoundEffect(
"block.fire.extinguish",
Vector3d(a_Block),