Archiviert
13
0

SPIGOT-892: Set chicken egg baby age before adding it to world.

Dieser Commit ist enthalten in:
md_5 2015-06-12 16:00:08 +10:00
Ursprung 0dfb243c86
Commit 994b2aae3f
2 geänderte Dateien mit 26 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -13,7 +13,7 @@
public class EntityEgg extends EntityProjectile {
public EntityEgg(World world) {
@@ -19,21 +26,36 @@
@@ -19,21 +26,37 @@
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F);
}
@ -53,10 +53,11 @@
- }
+ if (hatching) {
+ for (int k = 0; k < numHatching; k++) {
+ org.bukkit.entity.Entity entity = world.getWorld().spawn(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ if (entity instanceof Ageable) {
+ ((Ageable) entity).setBaby();
+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass());
+ if (entity.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entity.getBukkitEntity()).setBaby();
+ }
+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ }
}
+ // CraftBukkit end

Datei anzeigen

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@ -882,7 +883,7 @@ public class CraftWorld implements World {
}
@SuppressWarnings("unchecked")
public <T extends Entity> T spawn(Location location, Class<T> clazz, SpawnReason reason) throws IllegalArgumentException {
public net.minecraft.server.Entity createEntity(Location location, Class<? extends Entity> clazz) throws IllegalArgumentException {
if (location == null || clazz == null) {
throw new IllegalArgumentException("Location or entity class cannot be null");
}
@ -1108,17 +1109,30 @@ public class CraftWorld implements World {
}
if (entity != null) {
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
}
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
return entity;
}
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName());
}
@SuppressWarnings("unchecked")
public <T extends Entity> T addEntity(net.minecraft.server.Entity entity, SpawnReason reason) throws IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
}
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
}
public <T extends Entity> T spawn(Location location, Class<T> clazz, SpawnReason reason) throws IllegalArgumentException {
net.minecraft.server.Entity entity = createEntity(location, clazz);
return addEntity(entity, reason);
}
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain) {
return CraftChunk.getEmptyChunkSnapshot(x, z, this, includeBiome, includeBiomeTempRain);
}