From fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6 Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Wed, 20 Apr 2022 00:10:35 +0200 Subject: Valid Height is now checked by vector. --- src/Blocks/BlockButton.h | 2 +- src/Blocks/BlockFarmland.h | 2 +- src/Blocks/BlockFluid.h | 4 ++-- src/Blocks/BlockGrass.h | 4 ++-- src/Blocks/BlockHandler.cpp | 2 +- src/Blocks/BlockLever.h | 2 +- src/Blocks/BlockLilypad.h | 2 +- src/Blocks/BlockPiston.cpp | 6 +++--- src/Blocks/BlockVines.h | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/Blocks') diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h index 896fd58d6..d703d73bd 100644 --- a/src/Blocks/BlockButton.h +++ b/src/Blocks/BlockButton.h @@ -127,7 +127,7 @@ private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { auto SupportRelPos = AddFaceDirection(a_Position, BlockMetaDataToBlockFace(a_Meta), true); - if (!cChunkDef::IsValidHeight(SupportRelPos.y)) + if (!cChunkDef::IsValidHeight(SupportRelPos)) { return false; } diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 3d1666859..7ed1bb035 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -61,7 +61,7 @@ private: } // Farmland too dry. If nothing is growing on top, turn back to dirt: - auto UpperBlock = cChunkDef::IsValidHeight(a_RelPos.y + 1) ? a_Chunk.GetBlock(a_RelPos.addedY(1)) : E_BLOCK_AIR; + auto UpperBlock = cChunkDef::IsValidHeight(a_RelPos.addedY(1)) ? a_Chunk.GetBlock(a_RelPos.addedY(1)) : E_BLOCK_AIR; switch (UpperBlock) { case E_BLOCK_BEETROOTS: diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h index b39476c1d..ab71ee7c3 100644 --- a/src/Blocks/BlockFluid.h +++ b/src/Blocks/BlockFluid.h @@ -88,7 +88,7 @@ private: // Check if it's fuel: BLOCKTYPE BlockType; if ( - !cChunkDef::IsValidHeight(Pos.y) || + !cChunkDef::IsValidHeight(Pos) || !a_Chunk.UnboundedRelGetBlockType(Pos, BlockType) || !cFireSimulator::IsFuel(BlockType) ) @@ -110,7 +110,7 @@ private: { auto NeighborPos = Pos + CrossCoords[i]; if ( - cChunkDef::IsValidHeight(NeighborPos.y) && + cChunkDef::IsValidHeight(NeighborPos) && a_Chunk.UnboundedRelGetBlockType(NeighborPos, BlockType) && (BlockType == E_BLOCK_AIR) ) diff --git a/src/Blocks/BlockGrass.h b/src/Blocks/BlockGrass.h index 09af250c3..412291382 100644 --- a/src/Blocks/BlockGrass.h +++ b/src/Blocks/BlockGrass.h @@ -99,7 +99,7 @@ private: static Survivability DetermineSurvivability(cChunk & a_Chunk, const Vector3i a_RelPos) { const auto AbovePos = a_RelPos.addedY(1); - if (!cChunkDef::IsValidHeight(AbovePos.y)) + if (!cChunkDef::IsValidHeight(AbovePos)) { return Survivability::CanSpread; } @@ -126,7 +126,7 @@ private: /** Attempt to spread grass to a block at the given position. */ static void TrySpreadTo(cChunk & a_Chunk, Vector3i a_RelPos) { - if (!cChunkDef::IsValidHeight(a_RelPos.y)) + if (!cChunkDef::IsValidHeight(a_RelPos)) { // Y Coord out of range return; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index de9d37428..4b0d7e5ec 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -486,7 +486,7 @@ void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor) { - if (!cChunkDef::IsValidHeight(a_NeighborPos.y)) + if (!cChunkDef::IsValidHeight(a_NeighborPos)) { return; } diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h index ddb459fbe..bf6f911a1 100644 --- a/src/Blocks/BlockLever.h +++ b/src/Blocks/BlockLever.h @@ -94,7 +94,7 @@ private: // Find the type of block the lever is attached to: auto NeighborFace = BlockMetaDataToBlockFace(a_Meta); auto NeighborPos = AddFaceDirection(a_Position, NeighborFace, true); - if (!cChunkDef::IsValidHeight(NeighborPos.y)) + if (!cChunkDef::IsValidHeight(NeighborPos)) { return false; } diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h index 6d25a0e2d..e39d34566 100644 --- a/src/Blocks/BlockLilypad.h +++ b/src/Blocks/BlockLilypad.h @@ -31,7 +31,7 @@ private: virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override { auto UnderPos = a_Position.addedY(-1); - if (!cChunkDef::IsValidHeight(UnderPos.y)) + if (!cChunkDef::IsValidHeight(UnderPos)) { return false; } diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index afed8bae0..124757b44 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -215,7 +215,7 @@ bool cBlockPistonHandler::CanPushBlock( Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir ) { - if (!cChunkDef::IsValidHeight(a_BlockPos.y)) + if (!cChunkDef::IsValidHeight(a_BlockPos)) { // Can't push a void block. return false; @@ -299,7 +299,7 @@ void cBlockPistonHandler::OnBroken( const auto Extension = a_BlockPos + MetadataToOffset(a_OldBlockMeta); if ( - cChunkDef::IsValidHeight(Extension.y) && + cChunkDef::IsValidHeight(Extension) && (a_ChunkInterface.GetBlock(Extension) == E_BLOCK_PISTON_EXTENSION) ) { @@ -324,7 +324,7 @@ void cBlockPistonHeadHandler::OnBroken( { UNUSED(a_Digger); const auto Base = a_BlockPos - cBlockPistonHandler::MetadataToOffset(a_OldBlockMeta); - if (!cChunkDef::IsValidHeight(Base.y)) + if (!cChunkDef::IsValidHeight(Base)) { return; } diff --git a/src/Blocks/BlockVines.h b/src/Blocks/BlockVines.h index 0ab0441a8..a23ba1489 100644 --- a/src/Blocks/BlockVines.h +++ b/src/Blocks/BlockVines.h @@ -199,7 +199,7 @@ private: // Vine cannot grow down if at the bottom: auto GrowPos = a_RelPos.addedY(-1); - if (!cChunkDef::IsValidHeight(GrowPos.y)) + if (!cChunkDef::IsValidHeight(GrowPos)) { return; } -- cgit v1.2.3