Add aggressive mob API (#9838)

This commit is contained in:
booky10 2023-11-11 22:17:36 +01:00 committed by GitHub
parent dd47ec6fe2
commit 9ee60eca7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 89 additions and 16 deletions

View file

@ -8,10 +8,10 @@ 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..f2e3233a3d1744e32fb76d3731b9858ef0067e30 index 0000000000000000000000000000000000000000..b5eb4239763f8f919bc328d95c846d5ef1a9d24f
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java +++ b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
@@ -0,0 +1,31 @@ @@ -0,0 +1,35 @@
+package com.destroystokyo.paper.entity; +package com.destroystokyo.paper.entity;
+ +
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
@ -32,13 +32,17 @@ index 0000000000000000000000000000000000000000..f2e3233a3d1744e32fb76d3731b9858e
+ * 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();
+ } + }

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add more Zombie API
diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java
index 336b3efaf0a8ed5a238e8b941193d690e8b72d71..227560e04854088d162b4b6ed4cd1503d55c3200 100644 index 336b3efaf0a8ed5a238e8b941193d690e8b72d71..c1a5b625ea602d751a8026d989882c60e80756c9 100644
--- a/src/main/java/org/bukkit/entity/Zombie.java --- a/src/main/java/org/bukkit/entity/Zombie.java
+++ b/src/main/java/org/bukkit/entity/Zombie.java +++ b/src/main/java/org/bukkit/entity/Zombie.java
@@ -107,4 +107,56 @@ public interface Zombie extends Monster, Ageable { @@ -107,4 +107,60 @@ public interface Zombie extends Monster, Ageable {
* @param flag Whether this zombie can break doors * @param flag Whether this zombie can break doors
*/ */
void setCanBreakDoors(boolean flag); void setCanBreakDoors(boolean flag);
@ -40,14 +40,18 @@ index 336b3efaf0a8ed5a238e8b941193d690e8b72d71..227560e04854088d162b4b6ed4cd1503
+ * 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();
+ +
+ /** + /**

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Zombie API - breaking doors
diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java
index 227560e04854088d162b4b6ed4cd1503d55c3200..bb4f55f7d42d9789737f4b83974993aa166ca950 100644 index cb0d979257e6781b82926594472ca46e858dd6b1..453c8526445ba11e6a196b8e66105191b60f58d5 100644
--- a/src/main/java/org/bukkit/entity/Zombie.java --- a/src/main/java/org/bukkit/entity/Zombie.java
+++ b/src/main/java/org/bukkit/entity/Zombie.java +++ b/src/main/java/org/bukkit/entity/Zombie.java
@@ -100,8 +100,10 @@ public interface Zombie extends Monster, Ageable { @@ -100,8 +100,10 @@ public interface Zombie extends Monster, Ageable {
@ -21,7 +21,7 @@ index 227560e04854088d162b4b6ed4cd1503d55c3200..bb4f55f7d42d9789737f4b83974993aa
* the entity is currently breaking a door. * the entity is currently breaking a door.
* *
* @param flag Whether this zombie can break doors * @param flag Whether this zombie can break doors
@@ -158,5 +160,15 @@ public interface Zombie extends Monster, Ageable { @@ -162,5 +164,15 @@ public interface Zombie extends Monster, Ageable {
* @param shouldBurnInDay True to burn in sunlight * @param shouldBurnInDay True to burn in sunlight
*/ */
void setShouldBurnInDay(boolean shouldBurnInDay); void setShouldBurnInDay(boolean shouldBurnInDay);

View file

@ -633,6 +633,49 @@ index d23226ccb0f6c25028f000ce31346cd0a8898e6a..bc84b892cae5fe7019a3ad481e9da799
+ */ + */
+ @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 11b6d1aba7d1f6ae1f3c822193486f5a1478e105..709c8fc3dde786f45ff13d6ee6c405ffdc765282 100644
--- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -162,4 +162,38 @@ 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

View file

@ -5,13 +5,13 @@ Subject: [PATCH] Left handed API
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
index 11b6d1aba7d1f6ae1f3c822193486f5a1478e105..d53de07b40d9cd63a9553d4b0ad442d526530b92 100644 index 709c8fc3dde786f45ff13d6ee6c405ffdc765282..0c511b64672f9bafb92be3aea6bab8c1c12a7041 100644
--- a/src/main/java/org/bukkit/entity/Mob.java --- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -162,4 +162,20 @@ public interface Mob extends LivingEntity, Lootable { @@ -196,4 +196,20 @@ public interface Mob extends LivingEntity, Lootable {
*/ */
@Nullable void setAggressive(boolean aggressive);
public Sound getAmbientSound(); // Paper end
+ +
+ // Paper start + // Paper start
+ /** + /**

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add Mob Experience reward API
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
index d53de07b40d9cd63a9553d4b0ad442d526530b92..9e289e92ad76cf61d445b77e3765b0e3ea1abcf7 100644 index 0c511b64672f9bafb92be3aea6bab8c1c12a7041..30ef0c20df8ff2ed56adb40fea103265dd3e886c 100644
--- a/src/main/java/org/bukkit/entity/Mob.java --- a/src/main/java/org/bukkit/entity/Mob.java
+++ b/src/main/java/org/bukkit/entity/Mob.java +++ b/src/main/java/org/bukkit/entity/Mob.java
@@ -178,4 +178,13 @@ public interface Mob extends LivingEntity, Lootable { @@ -212,4 +212,13 @@ public interface Mob extends LivingEntity, Lootable {
*/ */
public void setLeftHanded(boolean leftHanded); public void setLeftHanded(boolean leftHanded);
// Paper end // Paper end

View file

@ -837,6 +837,27 @@ index 17f5684cba9d3ed22d9925d1951520cc4751dfe2..3a3563a1bdbc0d84d973b3a04b50b78b
+ 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 6152f4d3d58f4b598d5bd92dbd7c5428c5ff8bc5..a5d3845acc607f640dace05a85f0089611c7d23a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -148,4 +148,16 @@ 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

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/mai
index 6152f4d3d58f4b598d5bd92dbd7c5428c5ff8bc5..40d277f2737f1a060c3047313289c73307948e73 100644 index 6152f4d3d58f4b598d5bd92dbd7c5428c5ff8bc5..40d277f2737f1a060c3047313289c73307948e73 100644
--- 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
@@ -147,5 +147,15 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @@ -147,6 +147,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
public int getMaxHeadPitch() { public int getMaxHeadPitch() {
return getHandle().getMaxHeadXRot(); return getHandle().getMaxHeadXRot();
} }
@ -23,4 +23,5 @@ index 6152f4d3d58f4b598d5bd92dbd7c5428c5ff8bc5..40d277f2737f1a060c3047313289c733
+ getHandle().setLeftHanded(leftHanded); + getHandle().setLeftHanded(leftHanded);
+ } + }
// Paper end // Paper end
}
// Paper start

View file

@ -8,8 +8,8 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/mai
index 40d277f2737f1a060c3047313289c73307948e73..b4e45d8e9851552f30c9c29d3d9671e1e9094c38 100644 index 40d277f2737f1a060c3047313289c73307948e73..b4e45d8e9851552f30c9c29d3d9671e1e9094c38 100644
--- 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
@@ -158,4 +158,11 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @@ -170,4 +170,11 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
getHandle().setLeftHanded(leftHanded); this.getHandle().setAggressive(aggressive);
} }
// Paper end // Paper end
+ +