From 487f9a2aa9b5497495cef1ac3b9c7a603e69f862 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 21 Apr 2020 22:19:22 +0200 Subject: Vector3 in Handlers (#4680) Refactored all cBlockHandler and cItemHandler descendants to use Vector3. --- src/Entities/Pawn.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/Entities') diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index 109a1c70e..6a69cf6e5 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -331,10 +331,7 @@ void cPawn::HandleFalling(void) /* The blocks we're interested in relative to the player to account for larger than 1 blocks. This can be extended to do additional checks in case there are blocks that are represented as one block in memory but have a hitbox larger than 1 (like fences) */ - static const struct - { - int x, y, z; - } BlockSampleOffsets[] = + static const Vector3i BlockSampleOffsets[] = { { 0, 0, 0 }, // TODO: something went wrong here (offset 0?) { 0, -1, 0 }, // Potentially causes mis-detection (IsFootInWater) when player stands on block diagonal to water (i.e. on side of pool) @@ -354,26 +351,26 @@ void cPawn::HandleFalling(void) /* We go through the blocks that we consider "relevant" */ for (size_t j = 0; j < ARRAYCOUNT(BlockSampleOffsets); j++) { - Vector3i BlockTestPosition = CrossTestPosition.Floor() + Vector3i(BlockSampleOffsets[j].x, BlockSampleOffsets[j].y, BlockSampleOffsets[j].z); + Vector3i BlockTestPosition = CrossTestPosition.Floor() + BlockSampleOffsets[j]; if (!cChunkDef::IsValidHeight(BlockTestPosition.y)) { continue; } - BLOCKTYPE Block = GetWorld()->GetBlock(BlockTestPosition); + BLOCKTYPE BlockType = GetWorld()->GetBlock(BlockTestPosition); NIBBLETYPE BlockMeta = GetWorld()->GetBlockMeta(BlockTestPosition); /* we do the cross-shaped sampling to check for water / liquids, but only on our level because water blocks are never bigger than unit voxels */ if (j == 0) { - IsFootInWater |= IsBlockWater(Block); - IsFootInLiquid |= IsFootInWater || IsBlockLava(Block) || (Block == E_BLOCK_COBWEB); // okay so cobweb is not _technically_ a liquid... - IsFootOnSlimeBlock |= (Block == E_BLOCK_SLIME_BLOCK); + IsFootInWater |= IsBlockWater(BlockType); + IsFootInLiquid |= IsFootInWater || IsBlockLava(BlockType) || (BlockType == E_BLOCK_COBWEB); // okay so cobweb is not _technically_ a liquid... + IsFootOnSlimeBlock |= (BlockType == E_BLOCK_SLIME_BLOCK); } /* If the block is solid, and the blockhandler confirms the block to be inside, we're officially on the ground. */ - if ((cBlockInfo::IsSolid(Block)) && (cBlockInfo::GetHandler(Block)->IsInsideBlock(CrossTestPosition - BlockTestPosition, Block, BlockMeta))) + if ((cBlockInfo::IsSolid(BlockType)) && (cBlockInfo::GetHandler(BlockType)->IsInsideBlock(CrossTestPosition - BlockTestPosition, BlockMeta))) { OnGround = true; } -- cgit v1.2.3