private Cuboidd findSteppableCollisionbox(Cuboidd entityCollisionBox, double motionY, Vec3d walkVector) { Cuboidd stepableBox = null; for (int i = 0; i < collisionTester.CollisionBoxList.Count; i++) { Cuboidd collisionbox = collisionTester.CollisionBoxList.cuboids[i]; Block block = collisionTester.CollisionBoxList.blocks[i]; if (!block.CanStep) { continue; } EnumIntersect intersect = CollisionTester.AabbIntersect(collisionbox, entityCollisionBox, walkVector); if (intersect == EnumIntersect.NoIntersect) { continue; } // Already stuck somewhere? Can't step stairs // Would get stuck vertically if I go up? Can't step up either if ((intersect == EnumIntersect.Stuck && !block.AllowStepWhenStuck) || (intersect == EnumIntersect.IntersectY && motionY > 0)) { return(null); } double heightDiff = collisionbox.Y2 - entityCollisionBox.Y1; if (heightDiff <= 0) { continue; } if (heightDiff <= stepHeight) { stepableBox = collisionbox; } } return(stepableBox); }