SPIGOT-2151: Add support for getting simple bounding box of a block

This commit is contained in:
Evoluseis 2018-12-17 19:11:04 -05:00 committed by md_5
parent 4b843638ea
commit f55c819185

View File

@ -30,6 +30,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.BlockVector;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;
@ -648,4 +649,16 @@ public class CraftBlock implements Block {
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
}
@Override
public BoundingBox getBoundingBox() {
VoxelShape shape = getData0().g(world, position); // PAIL: getShape
if (shape.isEmpty()) {
return new BoundingBox(); // Return an empty bounding box if the block has no dimension
}
AxisAlignedBB aabb = shape.a(); // PAIL: getBoundingBox
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
}
}