From 6d67504ab5618f4f6d607fdd22bdd71d9a73f17d Mon Sep 17 00:00:00 2001 From: Owen <23108066+Owen1212055@users.noreply.github.com> Date: Mon, 17 Jan 2022 18:23:44 -0500 Subject: [PATCH] Expand Panda API (#7061) --- build-data/paper.at | 2 + .../0312-Missing-Entity-Behavior-API.patch | 117 ++++++++++++++++++ .../0682-Missing-Entity-Behavior-API.patch | 82 ++++++++++++ 3 files changed, 201 insertions(+) diff --git a/build-data/paper.at b/build-data/paper.at index fdecc391fd..335eb4626c 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -221,6 +221,8 @@ 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 +public net.minecraft.world.entity.animal.Panda getEatCounter()I +public net.minecraft.world.entity.animal.Panda setEatCounter(I)V # Cook speed multipler API public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity recipeType diff --git a/patches/api/0312-Missing-Entity-Behavior-API.patch b/patches/api/0312-Missing-Entity-Behavior-API.patch index e0b155bc4f..e0ed9f4cea 100644 --- a/patches/api/0312-Missing-Entity-Behavior-API.patch +++ b/patches/api/0312-Missing-Entity-Behavior-API.patch @@ -175,3 +175,120 @@ index 498e182846b81d50b3a594254e8b341fb23e8763..3826363a1954afcddaadec7f96ac1830 + public boolean isFaceplanted(); + // Paper end - Add more fox behavior API } +diff --git a/src/main/java/org/bukkit/entity/Panda.java b/src/main/java/org/bukkit/entity/Panda.java +index a6a7429ed2e1eefb2b12b7480ed74fcc3963a864..9d065625be5931d970d7f34e1225fae1af960314 100644 +--- a/src/main/java/org/bukkit/entity/Panda.java ++++ b/src/main/java/org/bukkit/entity/Panda.java +@@ -63,4 +63,112 @@ public interface Panda extends Animals { + return recessive; + } + } ++ ++ // Paper start - Panda API ++ /** ++ * Sets the sneeze progress in this animation. ++ * This value counts up only if {@link Panda#isSneezing()} is true ++ * ++ * @param ticks sneeze progress ++ */ ++ void setSneezeTicks(int ticks); ++ ++ /** ++ * Gets the current sneeze progress, or how many ticks this panda will sneeze for. ++ * ++ * @return sneeze progress ++ */ ++ int getSneezeTicks(); ++ ++ /** ++ * Sets if the panda is sneezing, which causes the sneeze counter to count. ++ *

++ * When false, this will automatically set the sneeze ticks to 0. ++ * ++ * @param sneeze if the panda is sneezing or not ++ */ ++ void setSneezing(boolean sneeze); ++ ++ /** ++ * Gets if the panda is sneezing ++ * ++ * @return is sneezing ++ */ ++ boolean isSneezing(); ++ ++ /** ++ * Sets the eating ticks for this panda. ++ *

++ * ++ * This starts counting up as long as it is greater than 0. ++ * ++ * @param ticks eating ticks ++ */ ++ void setEatingTicks(int ticks); ++ ++ /** ++ * Gets the current eating progress, or how many ticks this panda has been eating for. ++ * ++ * @return eating progress ++ */ ++ int getEatingTicks(); ++ ++ /** ++ * Sets the number of ticks this panda will be unhappy for. ++ *

++ * This value counts down. ++ * ++ * @param ticks unhappy ticks ++ */ ++ void setUnhappyTicks(int ticks); ++ ++ /** ++ * Gets how many ticks this panda will be unhappy for. ++ * ++ * @return unhappy ticks ++ */ ++ int getUnhappyTicks(); ++ ++ /** ++ * Sets if this panda is currently rolling. ++ * ++ * @param rolling should roll ++ */ ++ void setRolling(boolean rolling); ++ ++ /** ++ * Gets if this panda is currently rolling on the ground. ++ * ++ * @return is rolling ++ */ ++ boolean isRolling(); ++ ++ /** ++ * Sets if this panda is currently on its back. ++ * ++ * @param onBack is on its back ++ */ ++ void setIsOnBack(boolean onBack); ++ ++ /** ++ * Gets if this panda is currently on its back. ++ * ++ * @return is on back ++ */ ++ boolean isOnBack(); ++ ++ /** ++ * Sets if this panda is currently sitting. ++ * ++ * @param sitting is currently sitting ++ */ ++ void setIsSitting(boolean sitting); ++ ++ /** ++ * Gets if this panda is sitting. ++ * ++ * @return is sitting ++ */ ++ boolean isSitting(); ++ // Paper end - Panda API + } diff --git a/patches/server/0682-Missing-Entity-Behavior-API.patch b/patches/server/0682-Missing-Entity-Behavior-API.patch index d76fb77f09..da5322e4d3 100644 --- a/patches/server/0682-Missing-Entity-Behavior-API.patch +++ b/patches/server/0682-Missing-Entity-Behavior-API.patch @@ -156,3 +156,85 @@ index b647a5b9fdc1da61c4035d6f2cef7814033dc608..9795341efa748c2d94567e882cd5f26a + } + // Paper end - Add more fox behavior API } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +index 2d2620dbb16aec850e8afda02174508a4be5a313..ec56a520da22248cdcdfaa179489aa0db0f2273f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +@@ -46,6 +46,77 @@ public class CraftPanda extends CraftAnimals implements Panda { + public void setHiddenGene(Gene gene) { + this.getHandle().setHiddenGene(CraftPanda.toNms(gene)); + } ++ // Paper start - Panda API ++ @Override ++ public void setSneezeTicks(int ticks) { ++ this.getHandle().setSneezeCounter(ticks); ++ } ++ ++ @Override ++ public int getSneezeTicks() { ++ return this.getHandle().getSneezeCounter(); ++ } ++ ++ @Override ++ public void setSneezing(boolean sneeze) { ++ this.getHandle().sneeze(sneeze); ++ } ++ ++ @Override ++ public boolean isSneezing() { ++ return this.getHandle().isSneezing(); ++ } ++ ++ @Override ++ public void setEatingTicks(int ticks) { ++ this.getHandle().setEatCounter(ticks); ++ } ++ ++ @Override ++ public int getEatingTicks() { ++ return this.getHandle().getEatCounter(); ++ } ++ ++ @Override ++ public void setUnhappyTicks(int ticks) { ++ this.getHandle().setUnhappyCounter(ticks); ++ } ++ ++ @Override ++ public int getUnhappyTicks() { ++ return this.getHandle().getUnhappyCounter(); ++ } ++ ++ @Override ++ public boolean isRolling() { ++ return this.getHandle().isRolling(); ++ } ++ ++ @Override ++ public void setRolling(boolean rolling) { ++ this.getHandle().roll(rolling); ++ } ++ ++ @Override ++ public boolean isOnBack() { ++ return this.getHandle().isOnBack(); ++ } ++ ++ @Override ++ public void setIsOnBack(boolean onBack) { ++ this.getHandle().setOnBack(onBack); ++ } ++ ++ @Override ++ public boolean isSitting() { ++ return this.getHandle().isSitting(); ++ } ++ ++ @Override ++ public void setIsSitting(boolean sitting) { ++ this.getHandle().sit(sitting); ++ } ++ // Paper end - Panda API + + public static Gene fromNms(net.minecraft.world.entity.animal.Panda.Gene gene) { + Preconditions.checkArgument(gene != null, "Gene may not be null");