SPIGOT-4705: Revamp Ageable interface and add Breedable interface

By: Shane Bee <shanebolenback@me.com>
This commit is contained in:
CraftBukkit/Spigot 2020-08-13 11:18:47 +10:00
parent 5b931c0da0
commit 44ebf1c058
3 changed files with 129 additions and 0 deletions

View file

@ -52,6 +52,49 @@ public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract
getHandle().setBaby(flag); 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 @Override
public EntityPiglinAbstract getHandle() { public EntityPiglinAbstract getHandle() {
return (EntityPiglinAbstract) super.getHandle(); return (EntityPiglinAbstract) super.getHandle();

View file

@ -35,4 +35,47 @@ public class CraftZoglin extends CraftMonster implements Zoglin {
public EntityType getType() { public EntityType getType() {
return EntityType.ZOGLIN; 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) {
}
} }

View file

@ -80,4 +80,47 @@ public class CraftZombie extends CraftMonster implements Zombie {
getHandle().startDrownedConversion(time); 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) {
}
} }