This commit is contained in:
Owen 2024-04-29 13:54:13 +02:00 committed by GitHub
commit 50fb010997
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Fri, 9 Jun 2023 22:49:45 -0400
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..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
*/
@NotNull String getScoreboardEntryName();
// Paper end - entity scoreboard name
+ // Paper start - Player standing on position API
+ /**
+ * Gets the block that is currently being used to calculate movement effects (i.e friction) on the entity.
+ * <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).
+ *
+ * @return block used for movement affects
+ */
+ @NotNull
+ org.bukkit.block.Block getMovementAffectingBlock();
+
+ /**
+ * Gets the block that is currently supporting the entity.
+ * This takes into account the collisions of blocks under the entity.
+ * <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, as no block is 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();
+ // Paper end
}

View File

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Fri, 9 Jun 2023 22:49:38 -0400
Subject: [PATCH] Player standing on position API
== AT ==
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..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,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() {
+ return CraftBlock.at(this.getHandle().level(), this.getHandle().getBlockPosBelowThatAffectsMyMovement());
+ }
+
+ @Override
+ public org.bukkit.block.Block getSupportingBlock() {
+ return this.getHandle().mainSupportingBlockPos
+ .map((pos) -> CraftBlock.at(this.getHandle().level(), pos))
+ .orElse(null);
+ }
+ // Paper end - Player standing on position API
}