PaperMC/patches/api/0118-RangedEntity-API.patch

188 lines
7.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 26 Jun 2018 21:34:40 -0400
Subject: [PATCH] RangedEntity API
Allows you to determine if an entity is capable of ranged attacks,
and to perform an attack.
diff --git a/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
new file mode 100644
2023-11-13 19:25:46 +01:00
index 0000000000000000000000000000000000000000..a087a04c525ea14b197c65063b43ebf097ddc5c2
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
2023-11-11 22:17:36 +01:00
@@ -0,0 +1,35 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.entity;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Mob;
+import org.jetbrains.annotations.NotNull;
+
+public interface RangedEntity extends Mob {
+ /**
+ * Attack the specified entity using a ranged attack.
+ *
+ * @param target the entity to target
+ * @param charge How "charged" the attack is (how far back the bow was pulled for Bow attacks).
+ * This should be a value between 0 and 1, represented as targetDistance/maxDistance.
+ */
+ void rangedAttack(@NotNull LivingEntity target, float charge);
+
+ /**
+ * Sets that the Entity is "charging" up an attack, by raising its hands
+ *
+ * @param raiseHands Whether the entities hands are raised to charge attack
2023-11-13 19:25:46 +01:00
+ * @deprecated use {@link #setAggressive(boolean)}
2021-06-11 14:02:28 +02:00
+ */
2023-11-11 22:17:36 +01:00
+ @Deprecated
2021-06-11 14:02:28 +02:00
+ void setChargingAttack(boolean raiseHands);
+
+ /**
+ * Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
+ * @return If entities hands are raised
2023-11-11 22:17:36 +01:00
+ * @deprecated use {@link #isHandRaised()}
2021-06-11 14:02:28 +02:00
+ */
2023-11-11 22:17:36 +01:00
+ @Deprecated
2021-06-11 14:02:28 +02:00
+ default boolean isChargingAttack() {
+ return isHandRaised();
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/AbstractSkeleton.java b/src/main/java/org/bukkit/entity/AbstractSkeleton.java
index e2fce218c6623b3c932c2782a66dea73dccd33f1..4f4f1e48cdaee0d845f60666569e48731be3fbb9 100644
--- a/src/main/java/org/bukkit/entity/AbstractSkeleton.java
+++ b/src/main/java/org/bukkit/entity/AbstractSkeleton.java
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
* of this type, instanceOf checks against the specific subtypes listed prior
* are recommended.
*/
-public interface AbstractSkeleton extends Monster {
+public interface AbstractSkeleton extends Monster, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* Gets the current type of this skeleton.
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/entity/Drowned.java b/src/main/java/org/bukkit/entity/Drowned.java
index 1dee177ae6e21da000607dc8dd8fd76857f323b9..8d1ad9ef757cb1e8d72b145262df73612a76c746 100644
--- a/src/main/java/org/bukkit/entity/Drowned.java
+++ b/src/main/java/org/bukkit/entity/Drowned.java
@@ -1,6 +1,8 @@
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity;
+
/**
* Drowned zombie.
*/
-public interface Drowned extends Zombie { }
+public interface Drowned extends Zombie, RangedEntity { } // Paper
diff --git a/src/main/java/org/bukkit/entity/Illusioner.java b/src/main/java/org/bukkit/entity/Illusioner.java
index 7c92c431b32754dca12b4d584bd6fa93ff73badf..14e6c5ee06ece3d1bbc1239afa67c847a479948f 100644
--- a/src/main/java/org/bukkit/entity/Illusioner.java
+++ b/src/main/java/org/bukkit/entity/Illusioner.java
@@ -1,6 +1,10 @@
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity;
+
/**
* Represents an Illusioner "Illager".
*/
-public interface Illusioner extends Spellcaster { }
+public interface Illusioner extends Spellcaster, RangedEntity { // Paper
+
+}
diff --git a/src/main/java/org/bukkit/entity/Llama.java b/src/main/java/org/bukkit/entity/Llama.java
index c43854298548391679c1d280bd42edbeed7759b9..d23226ccb0f6c25028f000ce31346cd0a8898e6a 100644
--- a/src/main/java/org/bukkit/entity/Llama.java
+++ b/src/main/java/org/bukkit/entity/Llama.java
@@ -1,12 +1,13 @@
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity;
import org.bukkit.inventory.LlamaInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Llama.
*/
-public interface Llama extends ChestedHorse {
+public interface Llama extends ChestedHorse, RangedEntity { // Paper
/**
* Represents the base color that the llama has.
diff --git a/src/main/java/org/bukkit/entity/Piglin.java b/src/main/java/org/bukkit/entity/Piglin.java
index b96e57552245e2c6d452755d4227c572266fcec7..6fdc0e0bb62189dbf3cf9ce7a87b7fbb995956a3 100644
--- a/src/main/java/org/bukkit/entity/Piglin.java
+++ b/src/main/java/org/bukkit/entity/Piglin.java
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a Piglin.
*/
-public interface Piglin extends PiglinAbstract, InventoryHolder {
+public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* Get whether the piglin is able to hunt hoglins.
diff --git a/src/main/java/org/bukkit/entity/Pillager.java b/src/main/java/org/bukkit/entity/Pillager.java
index 9a2252fef56be1ed3ae2169aea46cb567e965c6c..11f38187fca830d974be01fea2966a31936184cb 100644
--- a/src/main/java/org/bukkit/entity/Pillager.java
+++ b/src/main/java/org/bukkit/entity/Pillager.java
@@ -1,8 +1,10 @@
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity; // Paper
+
import org.bukkit.inventory.InventoryHolder;
/**
* Illager entity.
*/
-public interface Pillager extends Illager, InventoryHolder { }
+public interface Pillager extends Illager, InventoryHolder, RangedEntity { } // Paper
diff --git a/src/main/java/org/bukkit/entity/Snowman.java b/src/main/java/org/bukkit/entity/Snowman.java
index 818efe2a4d1ac0c4d8dca6c757850d99cdc2cb4b..10f8f6d45ae9280651c3ebddd1f90acbd7d6ff29 100644
--- a/src/main/java/org/bukkit/entity/Snowman.java
+++ b/src/main/java/org/bukkit/entity/Snowman.java
@@ -1,9 +1,11 @@
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity;
+
/**
* Represents a snowman entity
*/
-public interface Snowman extends Golem {
+public interface Snowman extends Golem, RangedEntity { // Paper
/**
* Gets whether this snowman is in "derp mode", meaning it is not wearing a
diff --git a/src/main/java/org/bukkit/entity/Witch.java b/src/main/java/org/bukkit/entity/Witch.java
index 0ebd54df0bb072df25a6ebcf137a39829cf71bf9..6618f2129e108c0a6cd15f6d0e86426021b6ff0d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/Witch.java
+++ b/src/main/java/org/bukkit/entity/Witch.java
@@ -1,9 +1,11 @@
2021-06-11 14:02:28 +02:00
package org.bukkit.entity;
+import com.destroystokyo.paper.entity.RangedEntity;
+
/**
* Represents a Witch
*/
-public interface Witch extends Raider {
+public interface Witch extends Raider, RangedEntity { // Paper
/**
* Gets whether the witch is drinking a potion
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/entity/Wither.java b/src/main/java/org/bukkit/entity/Wither.java
2023-06-07 18:24:39 +02:00
index b3a5d7a91e483b9fd569dd3c8cec989498a50104..87a814f63c3f35be35bfa210c9248ad211c0dd8f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/Wither.java
+++ b/src/main/java/org/bukkit/entity/Wither.java
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
/**
* Represents a Wither boss
*/
-public interface Wither extends Monster, Boss {
+public interface Wither extends Monster, Boss, com.destroystokyo.paper.entity.RangedEntity { // Paper
/**
* {@inheritDoc}