Paper/patches/server/1030-Add-API-to-get-the-collision-shape-of-a-block-before.patch
Jake Potrebic 1e7dd72f15
Remove 'fix Vanilla Minecart speed' patch (#10068)
The game uses 0.95d now
2023-12-22 17:44:36 -08:00

33 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TrollyLoki <trollyloki@gmail.com>
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 c6a0fac2ee35056f31b60eebc364c7bda8252d74..c7b93b8d4ed15db0803e2304e2da70ed3624f13f 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
@@ -677,6 +677,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);