mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 08:57:35 +01:00
Add Sneaking API for Entities (#8485)
This commit is contained in:
parent
0262de0ddb
commit
28c7d40326
56
patches/api/0421-Add-Sneaking-API-for-Entities.patch
Normal file
56
patches/api/0421-Add-Sneaking-API-for-Entities.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dawon <dawon@dawon.eu>
|
||||
Date: Wed, 19 Oct 2022 23:36:42 +0200
|
||||
Subject: [PATCH] Add Sneaking API for Entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index 33a6b7a27dc91552799c07a7aad9b3df31ad13f7..cdbc7329cf5f67d66e31eb31e83b9e7997040f72 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -781,6 +781,25 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
@NotNull
|
||||
Pose getPose();
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Returns if the entity is in sneak mode
|
||||
+ *
|
||||
+ * @return true if the entity is in sneak mode
|
||||
+ */
|
||||
+ boolean isSneaking();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the sneak mode the entity.
|
||||
+ * <p>
|
||||
+ * Note: For most Entities this does not update Entity's pose
|
||||
+ * and just makes its name tag less visible.
|
||||
+ *
|
||||
+ * @param sneak true if the entity should be sneaking
|
||||
+ */
|
||||
+ void setSneaking(boolean sneak);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Get the category of spawn to which this entity belongs.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 19995314b01f19c312efa2a4584ccfba2d700c52..9f762cf670bf5db9138e468e72e57781d8d22f54 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -296,6 +296,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*
|
||||
* @return true if player is in sneak mode
|
||||
*/
|
||||
+ @Override // Paper
|
||||
public boolean isSneaking();
|
||||
|
||||
/**
|
||||
@@ -303,6 +304,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*
|
||||
* @param sneak true if player should appear sneaking
|
||||
*/
|
||||
+ @Override // Paper
|
||||
public void setSneaking(boolean sneak);
|
||||
|
||||
/**
|
29
patches/server/0949-Add-Sneaking-API-for-Entities.patch
Normal file
29
patches/server/0949-Add-Sneaking-API-for-Entities.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dawon <dawon@dawon.eu>
|
||||
Date: Wed, 19 Oct 2022 23:31:53 +0200
|
||||
Subject: [PATCH] Add Sneaking API for Entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 6cd6cb256bde958416a0e4b13fc1d3df74f230fd..78f53ee557276de85f0431ebcb146445b1f4fb92 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1160,6 +1160,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return Pose.values()[this.getHandle().getPose().ordinal()];
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setSneaking(boolean sneak) {
|
||||
+ this.getHandle().setShiftKeyDown(sneak);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isSneaking() {
|
||||
+ return this.getHandle().isShiftKeyDown();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public SpawnCategory getSpawnCategory() {
|
||||
return CraftSpawnCategory.toBukkit(this.getHandle().getType().getCategory());
|
Loading…
Reference in New Issue
Block a user