This commit is contained in:
Bjarne Koll 2024-01-27 21:08:58 +01:00
parent 92ef9d939b
commit 9691743a3e
No known key found for this signature in database
GPG Key ID: 27F6CCCF55D2EE62
2 changed files with 8 additions and 9 deletions

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Player standing on position API
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 6ace3581f8d0c2a1b7e2188d5b6af5c984b74a0e..144af73a97328604fe01061d8075ddbeb706244a 100644
index 6ace3581f8d0c2a1b7e2188d5b6af5c984b74a0e..b366bc329fc8714b4cb2e129f97bf9569ab9ade0 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -1107,4 +1107,30 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
@ -18,7 +18,7 @@ index 6ace3581f8d0c2a1b7e2188d5b6af5c984b74a0e..144af73a97328604fe01061d8075ddbe
+ * <p>
+ * Examples:
+ * - When standing on a slab under an ice block, this will return the position of the ice block.
+ * - When flying on top of a flower placed on a grass block this will return the position of the grass block (although this technically will not affect your movement).
+ * - When flying on top of a flower placed on a grass block, this will return the position of the grass block (although this technically will not affect your movement).
+ *
+ * @return block used for movement affects
+ */
@ -31,9 +31,9 @@ index 6ace3581f8d0c2a1b7e2188d5b6af5c984b74a0e..144af73a97328604fe01061d8075ddbe
+ * <p>
+ * Examples:
+ * - When standing on a slab under an ice block, this will return the position of the slab.
+ * - When flying on top of a flower placed on a grass block this will return null, because no block is holding your location.
+ * - When flying on top of a flower placed on a grass block, this will return null, as no block is supporting the entity.
+ *
+ * @return block currently supporting the entity, or null if a block is currently not supporting the entity
+ * @return block currently supporting the entity, or null if no block is currently supporting the entity
+ */
+ @Nullable
+ org.bukkit.block.Block getSupportingBlock();

View File

@ -7,24 +7,23 @@ Subject: [PATCH] Player standing on position API
public net.minecraft.world.entity.Entity getBlockPosBelowThatAffectsMyMovement()Lnet/minecraft/core/BlockPos;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 8698104e3eb98e2cc5da5de87a8f538860c1d91d..210b26850e609a2063bd317b1ee0df1a7fe9ba93 100644
index 8698104e3eb98e2cc5da5de87a8f538860c1d91d..601243b92d01210f48eddb798a501059a53e08f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1227,4 +1227,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1227,4 +1227,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.getHandle().getScoreboardName();
}
// Paper end - entity scoreboard name
+ // Paper start - Player standing on position API
+ @Override
+ public org.bukkit.block.Block getMovementAffectingBlock() {
+ net.minecraft.core.BlockPos blockPos = this.getHandle().getBlockPosBelowThatAffectsMyMovement();
+ return new org.bukkit.craftbukkit.block.CraftBlock(this.getHandle().level(), new net.minecraft.core.BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
+ return CraftBlock.at(this.getHandle().level(), this.getHandle().getBlockPosBelowThatAffectsMyMovement());
+ }
+
+ @Override
+ public org.bukkit.block.Block getSupportingBlock() {
+ return this.getHandle().mainSupportingBlockPos
+ .map((pos) -> new org.bukkit.craftbukkit.block.CraftBlock(this.getHandle().level(), new net.minecraft.core.BlockPos(pos.getX(), pos.getY(), pos.getZ())))
+ .map((pos) -> CraftBlock.at(this.getHandle().level(), pos))
+ .orElse(null);
+ }
+ // Paper end - Player standing on position API