Add methods to change entity physics (#10334)

This commit is contained in:
maxcom1
2024-03-23 22:26:17 +01:00
parent 0c76cbb7cc
commit 6a200a1663
11 changed files with 66 additions and 106 deletions

View File

@@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
boolean isInvisible();
// Paper end - move invisibility up to Entity
boolean hasNoPhysics();
// Paper end - missing entity api
+ // Paper start - Freeze Tick Lock API
+ /**

View File

@@ -1,43 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nesaak <52047222+Nesaak@users.noreply.github.com>
Date: Fri, 22 May 2020 13:35:21 -0400
Subject: [PATCH] Improve Arrow API
Add method to get the arrow's itemstack and a method
to set the arrow's "noclip" status
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/AbstractArrow.java
+++ b/src/main/java/org/bukkit/entity/AbstractArrow.java
@@ -0,0 +0,0 @@ public interface AbstractArrow extends Projectile {
}
// Paper start
+ /**
+ * Gets the ItemStack for this arrow.
+ *
+ * @return The ItemStack, as if a player picked up the arrow
+ */
+ @NotNull
+ org.bukkit.inventory.ItemStack getItemStack();
+
+ /**
+ * Sets this arrow to "noclip" status.
+ *
+ * @param noPhysics true to set "noclip"
+ */
+ void setNoPhysics(boolean noPhysics);
+
+ /**
+ * Gets if this arrow has "noclip".
+ *
+ * @return true if noclip is active
+ */
+ boolean hasNoPhysics();
+
/**
* Gets the {@link PickupRule} for this arrow.
*

View File

@@ -11,6 +11,7 @@ Co-authored-by: booky10 <boooky10@gmail.com>
Co-authored-by: Amin <amin.haddou@frg.wwschool.de>
Co-authored-by: TrollyLoki <trollyloki@gmail.com>
Co-authored-by: FireInstall <kettnerl@hu-berlin.de>
Co-authored-by: maxcom1 <46265094+maxcom1@users.noreply.github.com>
diff --git a/src/main/java/io/papermc/paper/entity/SchoolableFish.java b/src/main/java/io/papermc/paper/entity/SchoolableFish.java
new file mode 100644
@@ -423,7 +424,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
*/
boolean isFrozen();
+ // Paper start - move invisibility up to Entity
+ // Paper start - missing entity api
+ /**
+ * Sets whether the entity is invisible or not.
+ * <p>
@@ -433,15 +434,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param invisible If the entity is invisible
+ */
+ void setInvisible(boolean invisible);
+ void setInvisible(boolean invisible); // Paper - moved up from LivingEntity
+
+ /**
+ * Gets whether the entity is invisible or not.
+ *
+ * @return Whether the entity is invisible
+ */
+ boolean isInvisible();
+ // Paper end - move invisibility up to Entity
+ boolean isInvisible(); // Paper - moved up from LivingEntity
+
+ /**
+ * Sets this entities no physics status.
+ *
+ * @param noPhysics boolean indicating if the entity should not have physics.
+ */
+ void setNoPhysics(boolean noPhysics);
+
+ /**
+ * Gets if this entity has no physics.
+ *
+ * @return true if the entity does not have physics.
+ */
+ boolean hasNoPhysics();
+ // Paper end - missing entity api
+
/**
* Mark the entity's removal.

View File

@@ -10,9 +10,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/entity/AbstractArrow.java
+++ b/src/main/java/org/bukkit/entity/AbstractArrow.java
@@ -0,0 +0,0 @@ public interface AbstractArrow extends Projectile {
@NotNull
org.bukkit.inventory.ItemStack getItemStack();
ALLOWED,
CREATIVE_ONLY;
}
+
+ /**
+ * Gets the ItemStack for this arrow.
+ *
+ * @return The ItemStack, as if a player picked up the arrow
+ */
+ @NotNull
+ org.bukkit.inventory.ItemStack getItemStack();
+
+ /**
+ * Sets the amount of ticks this arrow has been alive in the world
+ * This is used to determine when the arrow should be automatically despawned.
@@ -42,10 +51,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @param sound sound that is played
+ */
+ void setHitSound(@NotNull org.bukkit.Sound sound);
+
/**
* Sets this arrow to "noclip" status.
*
// Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Firework.java b/src/main/java/org/bukkit/entity/Firework.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Firework.java