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
This commit is contained in:
UnknownShadow200 2020-04-25 21:01:29 +10:00
parent 94d154aa57
commit 24b4ede5fb

View File

@ -106,18 +106,18 @@ void RayTracer_Step(struct RayTracer* t) {
typedef cc_bool (*IntersectTest)(struct RayTracer* t); typedef cc_bool (*IntersectTest)(struct RayTracer* t);
static BlockID Picking_GetInside(int x, int y, int z) { static BlockID Picking_GetInside(int x, int y, int z) {
cc_bool sides; int floorY;
int height;
if (World_ContainsXZ(x, z)) { if (World_ContainsXZ(x, z)) {
if (y >= World.Height) return BLOCK_AIR; if (y >= World.Height) return BLOCK_AIR;
if (y >= 0) return World_GetBlock(x, y, z); if (y >= 0) return World_GetBlock(x, y, z);
floorY = 0;
} else {
floorY = Env_SidesHeight;
} }
/* bedrock on bottom or outside map */ /* bedrock on bottom or outside map */
sides = Env.SidesBlock != BLOCK_AIR; return Env.SidesBlock != BLOCK_AIR && y < floorY ? PICKING_BORDER : BLOCK_AIR;
height = Env_SidesHeight; if (height < 1) height = 1;
return sides && y < height ? PICKING_BORDER : BLOCK_AIR;
} }
static BlockID Picking_GetOutside(int x, int y, int z, IVec3 origin) { static BlockID Picking_GetOutside(int x, int y, int z, IVec3 origin) {