summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2022-04-20 00:10:35 +0200
committerAlexander Harkness <me@bearbin.net>2022-04-20 09:41:02 +0200
commitfe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6 (patch)
treea5c9f00728af0f2ca841bb5d881b8d0d785b24ae /src/Simulator
parentUpdated protocol functions to Vector3x (diff)
downloadcuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.gz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.bz2
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.lz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.xz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.zst
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.zip
Diffstat (limited to 'src/Simulator')
-rw-r--r--src/Simulator/DelayedFluidSimulator.cpp2
-rw-r--r--src/Simulator/FluidSimulator.cpp26
-rw-r--r--src/Simulator/FluidSimulator.h2
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.cpp4
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp2
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h2
-rw-r--r--src/Simulator/SimulatorManager.cpp2
7 files changed, 20 insertions, 20 deletions
diff --git a/src/Simulator/DelayedFluidSimulator.cpp b/src/Simulator/DelayedFluidSimulator.cpp
index 59f76a7f8..b7f7c890c 100644
--- a/src/Simulator/DelayedFluidSimulator.cpp
+++ b/src/Simulator/DelayedFluidSimulator.cpp
@@ -145,7 +145,7 @@ void cDelayedFluidSimulator::AddBlock(cChunk & a_Chunk, Vector3i a_Position, BLO
void cDelayedFluidSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
{
- if (!cChunkDef::IsValidHeight(a_Position.y))
+ if (!cChunkDef::IsValidHeight(a_Position))
{
// Not inside the world (may happen when rclk with a full bucket - the client sends Y = -1)
return;
diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp
index 0c4dc791d..968b8bd6e 100644
--- a/src/Simulator/FluidSimulator.cpp
+++ b/src/Simulator/FluidSimulator.cpp
@@ -130,14 +130,14 @@ bool cFluidSimulator::IsHigherMeta(NIBBLETYPE a_Meta1, NIBBLETYPE a_Meta2)
-Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z)
+Vector3f cFluidSimulator::GetFlowingDirection(Vector3i a_Pos)
{
- if (!cChunkDef::IsValidHeight(a_Y))
+ if (!cChunkDef::IsValidHeight(a_Pos))
{
return {};
}
- if (!IsAllowedBlock(m_World.GetBlock({ a_X, a_Y, a_Z }))) // No Fluid -> No Flowing direction :D
+ if (!IsAllowedBlock(m_World.GetBlock(a_Pos))) // No Fluid -> No Flowing direction :D
{
return {};
}
@@ -148,24 +148,24 @@ Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z)
return ((a_BlockMeta & 0x08) != 0) ? 0 : a_BlockMeta;
};
- auto BlockMeta = m_World.GetBlockMeta({ a_X, a_Y, a_Z });
+ auto BlockMeta = m_World.GetBlockMeta(a_Pos);
NIBBLETYPE CentralPoint = HeightFromMeta(BlockMeta);
NIBBLETYPE LevelPoint[4];
// blocks around the checking pos
- Vector3i Points[]
+ std::array<Vector3i, 4> Offsets {
{
- { a_X + 1, a_Y, a_Z },
- { a_X, a_Y, a_Z + 1 },
- { a_X - 1, a_Y, a_Z },
- { a_X, a_Y, a_Z - 1 }
- };
+ { 1, 0, 0 },
+ { 0, 0, 1 },
+ { 1, 0, 0 },
+ { 0, 0, 1 }
+ }};
- for (size_t i = 0; i < ARRAYCOUNT(LevelPoint); i++)
+ for (size_t i = 0; i < Offsets.size(); i++)
{
- if (IsAllowedBlock(m_World.GetBlock(Points[i])))
+ if (IsAllowedBlock(m_World.GetBlock(a_Pos + Offsets[i])))
{
- LevelPoint[i] = HeightFromMeta(m_World.GetBlockMeta(Points[i]));
+ LevelPoint[i] = HeightFromMeta(m_World.GetBlockMeta(Offsets[i]));
}
else
{
diff --git a/src/Simulator/FluidSimulator.h b/src/Simulator/FluidSimulator.h
index 2dc499375..3aa6deb8a 100644
--- a/src/Simulator/FluidSimulator.h
+++ b/src/Simulator/FluidSimulator.h
@@ -44,7 +44,7 @@ public:
cFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
/** Returns a unit vector in the direction the fluid is flowing or a zero-vector if not flowing. */
- virtual Vector3f GetFlowingDirection(int a_X, int a_Y, int a_Z);
+ virtual Vector3f GetFlowingDirection(Vector3i a_Pos);
/** Creates a ChunkData object for the simulator to use. The simulator returns the correct object type. */
virtual cFluidSimulatorData * CreateChunkData(void) = 0;
diff --git a/src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.cpp b/src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.cpp
index e8a8515eb..9c7560a6c 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator/ForEachSourceCallback.cpp
@@ -26,7 +26,7 @@ ForEachSourceCallback::ForEachSourceCallback(const cChunk & Chunk, const Vector3
void ForEachSourceCallback::operator()(Vector3i Location)
{
- if (!cChunkDef::IsValidHeight(Location.y))
+ if (!cChunkDef::IsValidHeight(Location))
{
return;
}
@@ -96,7 +96,7 @@ PowerLevel ForEachSourceCallback::QueryLinkedPower(const cChunk & Chunk, const V
for (const auto & Offset : cSimulator::GetLinkedOffsets(SolidBlockPosition - QueryPosition))
{
auto SourcePosition = QueryPosition + Offset;
- if (!cChunkDef::IsValidHeight(SourcePosition.y))
+ if (!cChunkDef::IsValidHeight(SourcePosition))
{
continue;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp
index c27f6d04d..c23af9f75 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.cpp
@@ -217,7 +217,7 @@ void cIncrementalRedstoneSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position
for (const auto & Offset : cSimulator::GetLinkedOffsets(a_Offset))
{
auto Relative = a_Position - a_Offset + Offset;
- if (!cChunkDef::IsValidHeight(Relative.y))
+ if (!cChunkDef::IsValidHeight(Relative))
{
continue;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h b/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
index cfdecb246..5f2026842 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
@@ -313,7 +313,7 @@ namespace RedstoneWireHandler
const auto YMDiagonalPosition = Relative + OffsetYM;
if (
BLOCKTYPE QueryBlock;
- cChunkDef::IsValidHeight(YMDiagonalPosition.y) &&
+ cChunkDef::IsValidHeight(YMDiagonalPosition) &&
a_Chunk.UnboundedRelGetBlockType(YMDiagonalPosition, QueryBlock) &&
(QueryBlock == E_BLOCK_REDSTONE_WIRE)
)
diff --git a/src/Simulator/SimulatorManager.cpp b/src/Simulator/SimulatorManager.cpp
index 8af56c791..321035de5 100644
--- a/src/Simulator/SimulatorManager.cpp
+++ b/src/Simulator/SimulatorManager.cpp
@@ -71,7 +71,7 @@ void cSimulatorManager::WakeUp(cChunk & a_Chunk, Vector3i a_Position)
for (const auto & Offset : cSimulator::AdjacentOffsets)
{
auto Relative = a_Position + Offset;
- if (!cChunkDef::IsValidHeight(Relative.y))
+ if (!cChunkDef::IsValidHeight(Relative))
{
continue;
}