Add API to get the collision shape of a block before it's placed

This commit is contained in:
TrollyLoki 2023-10-11 00:45:53 -04:00
parent 85e082a9b3
commit d30ecac57d

View file

@ -688,6 +688,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);