mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-17 06:48:23 +01:00
Add aggressive mob API (#9838)
This commit is contained in:
parent
5cca94a05e
commit
cbce3a66aa
7 changed files with 77 additions and 4 deletions
|
@ -40,14 +40,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Set if zombie has its arms raised
|
+ * Set if zombie has its arms raised
|
||||||
+ *
|
+ *
|
||||||
+ * @param raised True to raise arms
|
+ * @param raised True to raise arms
|
||||||
|
+ * @deprecated use {{@link #setAggressive(boolean)}}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ void setArmsRaised(boolean raised);
|
+ void setArmsRaised(boolean raised);
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Check if zombie has arms raised
|
+ * Check if zombie has arms raised
|
||||||
+ *
|
+ *
|
||||||
+ * @return True if arms are raised
|
+ * @return True if arms are raised
|
||||||
|
+ * @deprecated use {@link #isAggressive()}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ boolean isArmsRaised();
|
+ boolean isArmsRaised();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
|
|
@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+++ b/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 {
|
@@ -0,0 +0,0 @@ public interface Mob extends LivingEntity, Lootable {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
void setAggressive(boolean aggressive);
|
||||||
public Sound getAmbientSound();
|
// Paper end
|
||||||
+
|
+
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ /**
|
+ /**
|
||||||
|
|
|
@ -633,6 +633,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ */
|
+ */
|
||||||
+ @org.jetbrains.annotations.Nullable
|
+ @org.jetbrains.annotations.Nullable
|
||||||
+ Llama getCaravanTail();
|
+ 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
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
|
diff --git a/src/main/java/org/bukkit/entity/MushroomCow.java b/src/main/java/org/bukkit/entity/MushroomCow.java
|
||||||
|
|
|
@ -32,13 +32,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ * Sets that the Entity is "charging" up an attack, by raising its hands
|
+ * Sets that the Entity is "charging" up an attack, by raising its hands
|
||||||
+ *
|
+ *
|
||||||
+ * @param raiseHands Whether the entities hands are raised to charge attack
|
+ * @param raiseHands Whether the entities hands are raised to charge attack
|
||||||
|
+ * @deprecated use {@link #isAggressive()}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ void setChargingAttack(boolean raiseHands);
|
+ void setChargingAttack(boolean raiseHands);
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
|
+ * Alias to {@link LivingEntity#isHandRaised()}, if the entity is charging an attack
|
||||||
+ * @return If entities hands are raised
|
+ * @return If entities hands are raised
|
||||||
|
+ * @deprecated use {@link #isHandRaised()}
|
||||||
+ */
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
+ default boolean isChargingAttack() {
|
+ default boolean isChargingAttack() {
|
||||||
+ return isHandRaised();
|
+ return isHandRaised();
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||||
getHandle().setLeftHanded(leftHanded);
|
this.getHandle().setAggressive(aggressive);
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
+
|
+
|
||||||
|
|
|
@ -23,4 +23,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ getHandle().setLeftHanded(leftHanded);
|
+ getHandle().setLeftHanded(leftHanded);
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// Paper end
|
||||||
}
|
|
||||||
|
// Paper start
|
||||||
|
|
|
@ -837,6 +837,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public void setPickupCooldown(int cooldown) {
|
+ public void setPickupCooldown(int cooldown) {
|
||||||
+ throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns");
|
+ throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns");
|
||||||
+ }
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||||
|
return getHandle().getMaxHeadXRot();
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isAggressive() {
|
||||||
|
+ return this.getHandle().isAggressive();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setAggressive(boolean aggressive) {
|
||||||
|
+ this.getHandle().setAggressive(aggressive);
|
||||||
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java
|
||||||
|
|
Loading…
Reference in a new issue