Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
SPIGOT-892: Set chicken egg baby age before adding it to world.
Dieser Commit ist enthalten in:
Ursprung
0dfb243c86
Commit
994b2aae3f
@ -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
|
||||
|
@ -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,6 +1109,16 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
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);
|
||||
}
|
||||
@ -1116,7 +1127,10 @@ public class CraftWorld implements World {
|
||||
return (T) entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName());
|
||||
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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren