From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: TrollyLoki Date: Wed, 11 Oct 2023 00:45:53 -0400 Subject: [PATCH] Add API to get the collision shape of a block before it's placed diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index ef4d45ebfe84467454a209501dad7db7fb316416..9cf4ec4e1610d5f7cafbb90ef0310034cc818549 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -678,6 +678,20 @@ public class CraftBlockData implements BlockData { return this.state.isFaceSturdy(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CraftBlock.blockFaceToNotch(face), CraftBlockSupport.toNMS(support)); } + // Paper start + @Override + public org.bukkit.util.VoxelShape getCollisionShape(Location location) { + Preconditions.checkArgument(location != null, "location must not be null"); + + CraftWorld world = (CraftWorld) location.getWorld(); + Preconditions.checkArgument(world != null, "location must not have a null world"); + + BlockPos position = CraftLocation.toBlockPosition(location); + net.minecraft.world.phys.shapes.VoxelShape shape = this.state.getCollisionShape(world.getHandle(), position); + return new org.bukkit.craftbukkit.util.CraftVoxelShape(shape); + } + // Paper end + @Override public Color getMapColor() { return Color.fromRGB(this.state.getMapColor(null, null).col);