Add aggressive mob API (#9838)

This commit is contained in:
booky10
2023-11-11 22:17:36 +01:00
parent 5cca94a05e
commit cbce3a66aa
7 changed files with 77 additions and 4 deletions

View File

@@ -40,14 +40,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Set if zombie has its arms raised
+ *
+ * @param raised True to raise arms
+ * @deprecated use {{@link #setAggressive(boolean)}}
+ */
+ @Deprecated
+ void setArmsRaised(boolean raised);
+
+ /**
+ * Check if zombie has arms raised
+ *
+ * @return True if arms are raised
+ * @deprecated use {@link #isAggressive()}
+ */
+ @Deprecated
+ boolean isArmsRaised();
+
+ /**

View File

@@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
@Nullable
public Sound getAmbientSound();
void setAggressive(boolean aggressive);
// Paper end
+
+ // Paper start
+ /**

View File

@@ -633,6 +633,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ @org.jetbrains.annotations.Nullable
+ Llama getCaravanTail();
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
*/
@Nullable
public Sound getAmbientSound();
+
+ // Paper start
+ /**
+ * Some mobs will raise their arm(s) when aggressive:
+ * <ul>
+ * <li>{@link Drowned}</li>
+ * <li>{@link Piglin}</li>
+ * <li>{@link Skeleton}</li>
+ * <li>{@link Zombie}</li>
+ * <li>{@link ZombieVillager}</li>
+ * <li>{@link Illusioner}</li>
+ * <li>{@link Vindicator}</li>
+ * <li>{@link Panda}</li>
+ * <li>{@link Pillager}</li>
+ * <li>{@link PiglinBrute}</li>
+ * </ul>
+ * <p>
+ * Note: This doesn't always show the actual aggressive state as
+ * set by {@link #setAggressive(boolean)}. {@link Panda}'s are always
+ * aggressive if their combined {@link Panda.Gene} is {@link Panda.Gene#AGGRESSIVE}.
+ *
+ * @return wether the mob is aggressive or not
+ */
+ boolean isAggressive();
+
+ /**
+ * Some mobs will raise their arm(s) when aggressive,
+ * see {@link #isAggressive()} for full list.
+ *
+ * @param aggressive wether the mob should be aggressive or not
+ * @see #isAggressive()
+ */
+ void setAggressive(boolean aggressive);
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java

View File

@@ -32,13 +32,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Sets that the Entity is "charging" up an attack, by raising its hands
+ *
+ * @param raiseHands Whether the entities hands are raised to charge attack
+ * @deprecated use {@link #isAggressive()}
+ */
+ @Deprecated
+ void setChargingAttack(boolean raiseHands);
+
+ /**
+ * Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
+ * @return If entities hands are raised
+ * @deprecated use {@link #isHandRaised()}
+ */
+ @Deprecated
+ default boolean isChargingAttack() {
+ return isHandRaised();
+ }