From 24b4ede5fbd6285044c481d074b8c7b15ce1b672 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 25 Apr 2020 21:01:29 +1000 Subject: [PATCH] Fix rare wrong behaviour where block is picked with bedrock height <= 0 If bedrock height is <= 0 and you're inside the map and picking a block on horizontal border inside, you pick block above the border instead of the block of the border --- src/Picking.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Picking.c b/src/Picking.c index 444992d69..e937507f3 100644 --- a/src/Picking.c +++ b/src/Picking.c @@ -106,18 +106,18 @@ void RayTracer_Step(struct RayTracer* t) { typedef cc_bool (*IntersectTest)(struct RayTracer* t); static BlockID Picking_GetInside(int x, int y, int z) { - cc_bool sides; - int height; + int floorY; if (World_ContainsXZ(x, z)) { if (y >= World.Height) return BLOCK_AIR; if (y >= 0) return World_GetBlock(x, y, z); + floorY = 0; + } else { + floorY = Env_SidesHeight; } /* bedrock on bottom or outside map */ - sides = Env.SidesBlock != BLOCK_AIR; - height = Env_SidesHeight; if (height < 1) height = 1; - return sides && y < height ? PICKING_BORDER : BLOCK_AIR; + return Env.SidesBlock != BLOCK_AIR && y < floorY ? PICKING_BORDER : BLOCK_AIR; } static BlockID Picking_GetOutside(int x, int y, int z, IVec3 origin) {