From 44ebf1c05898016ae45c7fd3815745a0ca839265 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 13 Aug 2020 11:18:47 +1000 Subject: [PATCH] SPIGOT-4705: Revamp Ageable interface and add Breedable interface By: Shane Bee --- .../entity/CraftPiglinAbstract.java | 43 +++++++++++++++++++ .../craftbukkit/entity/CraftZoglin.java | 43 +++++++++++++++++++ .../craftbukkit/entity/CraftZombie.java | 43 +++++++++++++++++++ 3 files changed, 129 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java index b926d828e1..e165855394 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -52,6 +52,49 @@ public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract getHandle().setBaby(flag); } + @Override + public int getAge() { + return getHandle().isBaby() ? -1 : 0; + } + + @Override + public void setAge(int i) { + getHandle().setBaby(i < 0); + } + + @Override + public void setAgeLock(boolean b) { + } + + @Override + public boolean getAgeLock() { + return false; + } + + @Override + public void setBaby() { + getHandle().setBaby(true); + } + + @Override + public void setAdult() { + getHandle().setBaby(false); + } + + @Override + public boolean isAdult() { + return !getHandle().isBaby(); + } + + @Override + public boolean canBreed() { + return false; + } + + @Override + public void setBreed(boolean b) { + } + @Override public EntityPiglinAbstract getHandle() { return (EntityPiglinAbstract) super.getHandle(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java index e7e1782158..a0e323623b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -35,4 +35,47 @@ public class CraftZoglin extends CraftMonster implements Zoglin { public EntityType getType() { return EntityType.ZOGLIN; } + + @Override + public int getAge() { + return getHandle().isBaby() ? -1 : 0; + } + + @Override + public void setAge(int i) { + getHandle().setBaby(i < 0); + } + + @Override + public void setAgeLock(boolean b) { + } + + @Override + public boolean getAgeLock() { + return false; + } + + @Override + public void setBaby() { + getHandle().setBaby(true); + } + + @Override + public void setAdult() { + getHandle().setBaby(false); + } + + @Override + public boolean isAdult() { + return !getHandle().isBaby(); + } + + @Override + public boolean canBreed() { + return false; + } + + @Override + public void setBreed(boolean b) { + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 0429cf020e..2387f17acb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -80,4 +80,47 @@ public class CraftZombie extends CraftMonster implements Zombie { getHandle().startDrownedConversion(time); } } + + @Override + public int getAge() { + return getHandle().isBaby() ? -1 : 0; + } + + @Override + public void setAge(int i) { + getHandle().setBaby(i < 0); + } + + @Override + public void setAgeLock(boolean b) { + } + + @Override + public boolean getAgeLock() { + return false; + } + + @Override + public void setBaby() { + getHandle().setBaby(true); + } + + @Override + public void setAdult() { + getHandle().setBaby(false); + } + + @Override + public boolean isAdult() { + return !getHandle().isBaby(); + } + + @Override + public boolean canBreed() { + return false; + } + + @Override + public void setBreed(boolean b) { + } }