From f47aeafe0054ab75070a76cc79380d4501407ad3 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Wed, 20 Oct 2021 21:09:42 -0400 Subject: [PATCH] Add Horse Animation API (#5599) --- build-data/paper.at | 3 +- .../0319-Missing-Entity-Behavior-API.patch | 59 +++++++++++++++ .../0708-Missing-Entity-Behavior-API.patch | 72 +++++++++++++++++++ 3 files changed, 132 insertions(+), 2 deletions(-) diff --git a/build-data/paper.at b/build-data/paper.at index dd2b3c66b..a5d427669 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -210,10 +210,9 @@ public net.minecraft.world.entity.monster.Witch usingTime # PlayerDeathEvent#getItemsToKeep public net.minecraft.world.entity.player.Inventory compartments -# Missing Entity API +# Missing Entity Behavior API public net.minecraft.world.entity.animal.Fox isDefending()Z public net.minecraft.world.entity.animal.Fox setDefending(Z)V - public net.minecraft.world.entity.animal.Fox isFaceplanted()Z public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V diff --git a/patches/api/0319-Missing-Entity-Behavior-API.patch b/patches/api/0319-Missing-Entity-Behavior-API.patch index fc87b31d2..f2f7bbea3 100644 --- a/patches/api/0319-Missing-Entity-Behavior-API.patch +++ b/patches/api/0319-Missing-Entity-Behavior-API.patch @@ -4,6 +4,65 @@ Date: Fri, 28 May 2021 21:06:59 -0400 Subject: [PATCH] Missing Entity Behavior API +diff --git a/src/main/java/org/bukkit/entity/AbstractHorse.java b/src/main/java/org/bukkit/entity/AbstractHorse.java +index 2bbf1d074b7d46e176f2589db7abe5e3ef47871c..e023ed37963177e35bfe78105768ca6b2af6c2a1 100644 +--- a/src/main/java/org/bukkit/entity/AbstractHorse.java ++++ b/src/main/java/org/bukkit/entity/AbstractHorse.java +@@ -105,4 +105,54 @@ public interface AbstractHorse extends Vehicle, InventoryHolder, Tameable { + @NotNull + @Override + public AbstractHorseInventory getInventory(); ++ ++ // Paper start - Horse API ++ /** ++ * Gets if a horse is in their eating grass animation. ++ * ++ * @return eating grass animation is active ++ */ ++ public boolean isEatingGrass(); ++ ++ /** ++ * Sets if a horse is in their eating grass animation. ++ * ++ *

When true, the horse will lower its neck.

++ * ++ * @param eating eating grass animation is active ++ */ ++ public void setEatingGrass(boolean eating); ++ ++ /** ++ * Gets if a horse is in their rearing animation. ++ * ++ * @return rearing animation is active ++ */ ++ public boolean isRearing(); ++ ++ /** ++ * Sets if a horse is in their rearing animation. ++ * ++ *

When true, the horse will stand on its hind legs.

++ * ++ * @param rearing rearing animation is active ++ */ ++ public void setRearing(boolean rearing); ++ ++ /** ++ * Gets if a horse is in their eating animation. ++ * ++ * @return eating animation is active ++ */ ++ public boolean isEating(); ++ ++ /** ++ * Sets if a horse is in their eating animation. ++ * ++ *

When true, the horse will bob its head.

++ * ++ * @param eating eating animation is active ++ */ ++ public void setEating(boolean eating); ++ // Paper end - Horse API + } diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java index c2a566b864c82ffb094b7334d9e6e25a1bfc87d1..c340fecb61bac66baf0f44189d21bc85289b1269 100644 --- a/src/main/java/org/bukkit/entity/Cat.java diff --git a/patches/server/0708-Missing-Entity-Behavior-API.patch b/patches/server/0708-Missing-Entity-Behavior-API.patch index ea4e700c5..65f1fb5a1 100644 --- a/patches/server/0708-Missing-Entity-Behavior-API.patch +++ b/patches/server/0708-Missing-Entity-Behavior-API.patch @@ -4,6 +4,78 @@ Date: Mon, 21 Jun 2021 23:56:07 -0400 Subject: [PATCH] Missing Entity Behavior API +diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +index 630b6491ee186e1e3f17489311a91681e52b7ff5..bf610ede1232d18239f210d32db88466350c5aca 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java ++++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +@@ -658,6 +658,14 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, + + } + ++ // Paper Start - Horse API ++ public void setMouthOpen(boolean open) { ++ this.setFlag(FLAG_OPEN_MOUTH, open); ++ } ++ public boolean isMouthOpen() { ++ return this.getFlag(FLAG_OPEN_MOUTH); ++ } ++ // Paper End - Horse API + private void openMouth() { + if (!this.level.isClientSide) { + this.mouthCounter = 1; +@@ -670,6 +678,11 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, + this.setFlag(16, eatingGrass); + } + ++ // Paper Start - Horse API ++ public void setForceStanding(boolean standing) { ++ this.setFlag(FLAG_STANDING, standing); ++ } ++ // Paper End - Horse API + public void setStanding(boolean angry) { + if (angry) { + this.setEating(false); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +index 69c95644b2531c1fe1c4a6cf7fee12e997dd67f4..ff2bbdfd01b8fbcae6630184d5bc5954f13a8f2e 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +@@ -105,4 +105,36 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac + public AbstractHorseInventory getInventory() { + return new CraftSaddledInventory(getHandle().inventory); + } ++ ++ // Paper start - Horse API ++ @Override ++ public boolean isEatingGrass() { ++ return this.getHandle().isEating(); ++ } ++ ++ @Override ++ public void setEatingGrass(boolean eating) { ++ this.getHandle().setEating(eating); ++ } ++ ++ @Override ++ public boolean isRearing() { ++ return this.getHandle().isStanding(); ++ } ++ ++ @Override ++ public void setRearing(boolean rearing) { ++ this.getHandle().setForceStanding(rearing); ++ } ++ ++ @Override ++ public boolean isEating() { ++ return this.getHandle().isMouthOpen(); ++ } ++ ++ @Override ++ public void setEating(boolean eating) { ++ this.getHandle().setMouthOpen(eating); ++ } ++ // Paper end - Horse API + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index a4f909123de26d911aea7cd767d2315ed1f697c9..0eee53c068bca070a86645d0ba54fb1ad49a6a5b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java