mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 05:55:44 +01:00
e339ec27b4
The method sadly is not usable in 1.21 without a player as all of an enchantments attribtue modifiers rely on a base value supplied by a player. The method could only offer a rough estimate based on some default values, however a better method for this should be added down the line rather than trying to force such logic into the existing one.
33 lines
1.6 KiB
Diff
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 53dddaf1fb608312991739d488b8cd2dadc58e22..17933c51abf657335fd449635f198c6802adf14c 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);
|