summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvoluseis <contact@evoluseis.me>2018-12-17 19:11:04 -0500
committermd_5 <git@md-5.net>2018-12-19 10:34:47 +1100
commitf55c8191850d21599ee8abde2d378cfff3154f80 (patch)
tree92f1d9dc79638d96085c7d2060516de68ba960c1
parent4b843638ea8f10752363eb97e455174dfef19d46 (diff)
downloadcraftbukkit-f55c8191850d21599ee8abde2d378cfff3154f80.tar
craftbukkit-f55c8191850d21599ee8abde2d378cfff3154f80.tar.gz
craftbukkit-f55c8191850d21599ee8abde2d378cfff3154f80.tar.lz
craftbukkit-f55c8191850d21599ee8abde2d378cfff3154f80.tar.xz
craftbukkit-f55c8191850d21599ee8abde2d378cfff3154f80.zip
SPIGOT-2151: Add support for getting simple bounding box of a block
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 1fadbf05..89c67aa2 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -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);
+ }
}