From e68fd7162a137d9e243d921c3a85d13c5f7b2b46 Mon Sep 17 00:00:00 2001 From: Duckulus <76813487+Duckulus@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:54:43 +0200 Subject: [PATCH] Add missing Piglin Dancing API (#8894) --- patches/api/0299-Missing-Entity-API.patch | 27 ++++++++++++++++++-- patches/server/0631-Missing-Entity-API.patch | 27 ++++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/patches/api/0299-Missing-Entity-API.patch b/patches/api/0299-Missing-Entity-API.patch index 1dd76c16e9..94533104e9 100644 --- a/patches/api/0299-Missing-Entity-API.patch +++ b/patches/api/0299-Missing-Entity-API.patch @@ -8,6 +8,7 @@ Co-authored-by: Jake Potrebic Co-authored-by: William Blake Galbreath Co-authored-by: SoSeDiK Co-authored-by: booky10 +Co-authored-by: Amin diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index c9837c7c47314b5bdf6c7973e6bc962d390dc13d..b7a2cecb334ce39fa09d8ab949a29eedbdc44c36 100644 @@ -736,10 +737,10 @@ index 3dafdf14ced991ae1179ef1ca455da62f8c3243e..2fe8e8868f12bd9e846baf8858cd2c33 // Paper end } diff --git a/src/main/java/org/bukkit/entity/Piglin.java b/src/main/java/org/bukkit/entity/Piglin.java -index 6fdc0e0bb62189dbf3cf9ce7a87b7fbb995956a3..d4cb4b0ed1d9766a87867dcf1a3a839526ba9332 100644 +index 6fdc0e0bb62189dbf3cf9ce7a87b7fbb995956a3..eb0b7c18c1266748ff1e8e18e49b6c4f6e078b83 100644 --- a/src/main/java/org/bukkit/entity/Piglin.java +++ b/src/main/java/org/bukkit/entity/Piglin.java -@@ -90,4 +90,25 @@ public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystok +@@ -90,4 +90,47 @@ public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystok */ @NotNull public Set getBarterList(); @@ -762,6 +763,28 @@ index 6fdc0e0bb62189dbf3cf9ce7a87b7fbb995956a3..d4cb4b0ed1d9766a87867dcf1a3a8395 + * @return is charging + */ + boolean isChargingCrossbow(); ++ ++ /** ++ * Sets whether the Piglin is dancing or not ++ * ++ * @param dancing is dancing ++ */ ++ void setDancing(boolean dancing); ++ ++ /** ++ * Causes the piglin to dance for a ++ * specified amount of time ++ * ++ * @param duration duration of the dance in ticks ++ */ ++ void setDancing(long duration); ++ ++ /** ++ * Gets if the piglin is currently dancing ++ * ++ * @return is dancing ++ */ ++ boolean isDancing(); + // Paper end + } diff --git a/patches/server/0631-Missing-Entity-API.patch b/patches/server/0631-Missing-Entity-API.patch index 370c72c38e..11ac90644c 100644 --- a/patches/server/0631-Missing-Entity-API.patch +++ b/patches/server/0631-Missing-Entity-API.patch @@ -37,6 +37,7 @@ Co-authored-by: Jake Potrebic Co-authored-by: William Blake Galbreath Co-authored-by: SoSeDiK Co-authored-by: booky10 +Co-authored-by: Amin diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index f80a6ad7638453348ee82ea00b166a3aac029142..a08c00b8c0488d18be5e182f7892e5ab71d12247 100644 @@ -924,10 +925,10 @@ index 9304e201db1ec96d0916aa8ea781f3e4bc7991e6..8338effd39b1709dbe578e247710a8e5 // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java -index 8b9695de6e3411cbcc2f97e4a4e243ec1d1dd076..f69c81e801569deae8a2536a1a57767cd2e3897f 100644 +index 8b9695de6e3411cbcc2f97e4a4e243ec1d1dd076..03e74b29ebf0f9b9a0dbc6ffc872e22a22be20f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java -@@ -84,4 +84,15 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest +@@ -84,4 +84,37 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest public String toString() { return "CraftPiglin"; } @@ -941,6 +942,28 @@ index 8b9695de6e3411cbcc2f97e4a4e243ec1d1dd076..f69c81e801569deae8a2536a1a57767c + public boolean isChargingCrossbow() { + return this.getHandle().isChargingCrossbow(); + } ++ ++ @Override ++ public void setDancing(boolean dancing) { ++ if (dancing) { ++ this.getHandle().getBrain().setMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING, true); ++ this.getHandle().getBrain().setMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION, this.getHandle().getOnPos()); ++ } else { ++ this.getHandle().getBrain().eraseMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING); ++ this.getHandle().getBrain().eraseMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION); ++ } ++ } ++ ++ @Override ++ public void setDancing(long duration) { ++ this.getHandle().getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING, true, duration); ++ this.getHandle().getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION, this.getHandle().getOnPos(), duration); ++ } ++ ++ @Override ++ public boolean isDancing() { ++ return this.getHandle().isDancing(); ++ } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java