Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 21:10:10 +01:00
[Bleeding] Added Ageable interface for Villagers and Animals to extend. Addresses BUKKIT-1232
Dieser Commit ist enthalten in:
Ursprung
96c4bb7da6
Commit
169c2ee8cb
@ -2,7 +2,7 @@ package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
@ -51,8 +51,8 @@ public class EntityEgg extends EntityProjectile {
|
||||
for (int k = 0; k < numHatching; k++) {
|
||||
org.bukkit.entity.Entity entity = world.getWorld().spawn(new Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), SpawnReason.EGG);
|
||||
|
||||
if (entity instanceof Animals) {
|
||||
((Animals) entity).setBaby();
|
||||
if (entity instanceof Ageable) {
|
||||
((Ageable) entity).setBaby();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java
Normale Datei
67
src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java
Normale Datei
@ -0,0 +1,67 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityAgeable;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Ageable;
|
||||
|
||||
public class CraftAgeable extends CraftCreature implements Ageable {
|
||||
public CraftAgeable(CraftServer server, EntityAgeable entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return getHandle().getAge();
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
getHandle().setAge(age);
|
||||
}
|
||||
|
||||
public void setAgeLock(boolean lock) {
|
||||
getHandle().ageLocked = lock;
|
||||
}
|
||||
|
||||
public boolean getAgeLock() {
|
||||
return getHandle().ageLocked;
|
||||
}
|
||||
|
||||
public void setBaby() {
|
||||
if (isAdult()) {
|
||||
setAge(-24000);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdult() {
|
||||
if (!isAdult()) {
|
||||
setAge(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAdult() {
|
||||
return getAge() >= 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean canBreed() {
|
||||
return getAge() == 0;
|
||||
}
|
||||
|
||||
public void setBreed(boolean breed) {
|
||||
if (breed) {
|
||||
setAge(0);
|
||||
} else if (isAdult()) {
|
||||
setAge(6000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityAgeable getHandle() {
|
||||
return (EntityAgeable) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftAgeable";
|
||||
}
|
||||
}
|
@ -4,61 +4,17 @@ import net.minecraft.server.EntityAnimal;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Animals;
|
||||
|
||||
public class CraftAnimals extends CraftCreature implements Animals {
|
||||
public class CraftAnimals extends CraftAgeable implements Animals {
|
||||
|
||||
public CraftAnimals(CraftServer server, EntityAnimal entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return getHandle().getAge();
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
getHandle().setAge(age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityAnimal getHandle() {
|
||||
return (EntityAnimal) entity;
|
||||
}
|
||||
|
||||
public void setAgeLock(boolean lock) {
|
||||
getHandle().ageLocked = lock;
|
||||
}
|
||||
|
||||
public boolean getAgeLock() {
|
||||
return getHandle().ageLocked;
|
||||
}
|
||||
|
||||
public void setBaby() {
|
||||
if (isAdult()) {
|
||||
setAge(-24000);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdult() {
|
||||
if (!isAdult()) {
|
||||
setAge(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAdult() {
|
||||
return getAge() >= 0;
|
||||
}
|
||||
|
||||
public boolean canBreed() {
|
||||
return getAge() == 0;
|
||||
}
|
||||
|
||||
public void setBreed(boolean breed) {
|
||||
if (breed) {
|
||||
setAge(0);
|
||||
} else if (isAdult()) {
|
||||
setAge(6000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftAnimals";
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
|
||||
public class CraftVillager extends CraftCreature implements Villager {
|
||||
public class CraftVillager extends CraftAgeable implements Villager {
|
||||
public CraftVillager(CraftServer server, EntityVillager entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren