From affb89f9a2ce47bff50f51a3df9c959a1a6e8cd7 Mon Sep 17 00:00:00 2001 From: Owen1212055 <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 + patches/api/Missing-Entity-Behavior-API.patch | 117 ++++++++++++++++++ .../server/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/Missing-Entity-Behavior-API.patch b/patches/api/Missing-Entity-Behavior-API.patch index 97cf6e63e7..9fe40a4c68 100644 --- a/patches/api/Missing-Entity-Behavior-API.patch +++ b/patches/api/Missing-Entity-Behavior-API.patch @@ -175,3 +175,120 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Panda.java ++++ b/src/main/java/org/bukkit/entity/Panda.java +@@ -0,0 +0,0 @@ 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/Missing-Entity-Behavior-API.patch b/patches/server/Missing-Entity-Behavior-API.patch index a263e14473..61f8e4bd7b 100644 --- a/patches/server/Missing-Entity-Behavior-API.patch +++ b/patches/server/Missing-Entity-Behavior-API.patch @@ -156,3 +156,85 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +@@ -0,0 +0,0 @@ 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");