From a4a40685d8d7db2366a630e6a95f8394455e544c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 15 Feb 2017 11:27:24 +1100 Subject: [PATCH] Fix ZS noclip detection with custom blocks --- MCGalaxy/util/Math/AABB.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/MCGalaxy/util/Math/AABB.cs b/MCGalaxy/util/Math/AABB.cs index 69de1f9b9..ef70a9589 100644 --- a/MCGalaxy/util/Math/AABB.cs +++ b/MCGalaxy/util/Math/AABB.cs @@ -28,11 +28,11 @@ namespace MCGalaxy { /// Fixed-point max coordinate of this bounding box. public Vec3S32 Max; - /// World/block coordinate of the min coordinate of this bounding box. + /// World/block coordinate of the min coordinate of this bounding box. public Vec3S32 BlockMin { get { return new Vec3S32(Min.X >> 5, Min.Y >> 5, Min.Z >> 5); } } - /// World/block coordinate of the max coordinate of this bounding box. - public Vec3S32 BlockMax { get { return new Vec3S32(Max.X >> 5, Max.Y >> 5, Max.Z >> 5); } } + /// World/block coordinate of the max coordinate of this bounding box. + public Vec3S32 BlockMax { get { return new Vec3S32(Max.X >> 5, Max.Y >> 5, Max.Z >> 5); } } public AABB(int x1, int y1, int z1, int x2, int y2, int z2) { @@ -114,15 +114,15 @@ namespace MCGalaxy { byte block; if (byte.TryParse(model, out block)) { byte extBlock = 0; - // For model, not a physics blocks means custom block + // For model, not a physics blocks means custom block if (block >= Block.CpeCount) { extBlock = block; block = Block.custom_block; } baseBB = Block.BlockAABB(block, extBlock, lvl); baseBB = baseBB.Offset(-16, 0, -16); // centre around [-16, 16] instead of [0, 32] - baseBB = baseBB.Expand(-1); // adjust the block inwards slightly } else { baseBB = AABB.Make(new Vec3S32(0, 0, 0), BaseSize(model)); } + baseBB = baseBB.Expand(-1); // adjust the model AABB inwards slightly float scale; if (!Utils.TryParseDecimal(scaleStr, out scale)) return baseBB; @@ -159,11 +159,12 @@ namespace MCGalaxy { .Offset(x * 32, y * 32, z * 32); if (!bb.Intersects(blockBB)) continue; - if (!Block.Walkthrough(Block.Convert(block))) return true; - if (block != Block.custom_block) continue; - - BlockDefinition def = lvl.CustomBlockDefs[extBlock]; - if (def == null || def.CollideType == CollideType.Solid) return true; + if (block == Block.custom_block) { + if (!Block.Walkthrough(Block.Convert(block))) return true; + } else { + BlockDefinition def = lvl.CustomBlockDefs[extBlock]; + if (def == null || def.CollideType == CollideType.Solid) return true; + } } return false; }