aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0903-Add-API-to-get-the-collision-shape-of-a-block-before.patch
blob: f0fcc8b9eb8823aea7357fa8389d30eb5ce2dd3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 64ddd6d1c40dc91b6e7fc3118403415bb4533d97..0daa0bf7e56aa7228d89867500cb780b37f06541 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
@@ -679,6 +679,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);