mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-26 01:12:20 +01:00
Player standing on position API
This commit is contained in:
parent
b3c81089ae
commit
d000933c6f
55
patches/api/0419-Player-standing-on-position-API.patch
Normal file
55
patches/api/0419-Player-standing-on-position-API.patch
Normal file
@ -0,0 +1,55 @@
|
||||
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 a2a423d4e4c2702ba5967223cab0432dd7d04732..6fa7d251f54be9d0ef6b0ec0283efa927bae1a0b 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -954,4 +954,44 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
*/
|
||||
boolean wouldCollideUsing(@NotNull BoundingBox boundingBox);
|
||||
// Paper End - Collision API
|
||||
+ // Paper start - Player standing on position API
|
||||
+ /**
|
||||
+ * Gets the block that is currently being used to calculate movement affects (i.e friction) on the entity.
|
||||
+ * <p>
|
||||
+ * Examples:
|
||||
+ * - When sanding on a slab under an ice block, this will return the position of the ice block.
|
||||
+ * - When flying on top of a flower located under a grass block this will return the position of the grass block (although this technically will not affect your movement).
|
||||
+ *
|
||||
+ * @return block position used for movement affects
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ io.papermc.paper.math.BlockPosition getBlockPosBelowThatAffectsMyMovement();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the block that is currently under the entity.
|
||||
+ * This will return {@link Entity#getSupportingPos()} as long as it is not null,
|
||||
+ * else it will instead return the bottom most block at the entity's hitbox.
|
||||
+ * <p>
|
||||
+ * Examples:
|
||||
+ * - When sanding on a slab under an ice block, this will return the position of the slab.
|
||||
+ * - When flying on top of a flower located under a grass block this will return the position of the corn flower.
|
||||
+ *
|
||||
+ * @return {@link Entity#getSupportingPos()} if not null or the entity's bottom most block
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ io.papermc.paper.math.BlockPosition getOnPos();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the block that is currently supporting the entity.
|
||||
+ * This takes into account the collisions of blocks under the entity.
|
||||
+ * <p>
|
||||
+ * Examples:
|
||||
+ * - When sanding on a slab under an ice block, this will return the position of the slab.
|
||||
+ * - When flying on top of a flower located under a grass block this will return null, because no block is holding your location.
|
||||
+ *
|
||||
+ * @return block position currently supporting the entity, or null if a block is currently not supporting the entity
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ io.papermc.paper.math.BlockPosition getSupportingPos();
|
||||
+ // Paper end
|
||||
}
|
35
patches/server/0977-Player-standing-on-position-API.patch
Normal file
35
patches/server/0977-Player-standing-on-position-API.patch
Normal file
@ -0,0 +1,35 @@
|
||||
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
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index ea056babe2f8123f20dc608d8a636da1de634b8c..146019c3021439d5738fe0b32cb05b28ad8ce78f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1442,4 +1442,24 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return !this.getHandle().level().noCollision(this.getHandle(), aabb);
|
||||
}
|
||||
// Paper End - Collision API
|
||||
+ // Paper start - Player standing on position API
|
||||
+ @Override
|
||||
+ public io.papermc.paper.math.BlockPosition getBlockPosBelowThatAffectsMyMovement() {
|
||||
+ net.minecraft.core.BlockPos blockPos = this.getHandle().getBlockPosBelowThatAffectsMyMovement();
|
||||
+ return io.papermc.paper.math.Position.block(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.math.BlockPosition getOnPos() {
|
||||
+ net.minecraft.core.BlockPos blockPos = this.getHandle().getOnPos();
|
||||
+ return io.papermc.paper.math.Position.block(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.math.BlockPosition getSupportingPos() {
|
||||
+ return this.getHandle().mainSupportingBlockPos
|
||||
+ .map((func) -> io.papermc.paper.math.Position.block(func.getX(), func.getY(), func.getZ()))
|
||||
+ .orElse(null);
|
||||
+ }
|
||||
+ // Paper end - Player standing on position API
|
||||
}
|
Loading…
Reference in New Issue
Block a user