Add missing Piglin Dancing API (#8894)

This commit is contained in:
Duckulus 2023-09-14 12:54:43 +02:00 committed by GitHub
parent eea0c649ca
commit e68fd7162a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 4 deletions

View file

@ -8,6 +8,7 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
Co-authored-by: booky10 <boooky10@gmail.com>
Co-authored-by: Amin <amin.haddou@frg.wwschool.de>
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<Material> 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
+
}

View file

@ -37,6 +37,7 @@ Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
Co-authored-by: booky10 <boooky10@gmail.com>
Co-authored-by: Amin <amin.haddou@frg.wwschool.de>
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