#1209: Clean up various patches
By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
@@ -16,28 +16,28 @@
|
||||
public class EntityEgg extends EntityProjectileThrowable {
|
||||
|
||||
public EntityEgg(EntityTypes<? extends EntityEgg> entitytypes, World world) {
|
||||
@@ -47,22 +56,42 @@
|
||||
@@ -47,20 +56,47 @@
|
||||
protected void onHit(MovingObjectPosition movingobjectposition) {
|
||||
super.onHit(movingobjectposition);
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(8) == 0) {
|
||||
+ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ boolean hatching = this.random.nextInt(8) == 0;
|
||||
+ if (true) {
|
||||
+ // CraftBukkit end
|
||||
byte b0 = 1;
|
||||
|
||||
if (this.random.nextInt(32) == 0) {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
- for (int i = 0; i < b0; ++i) {
|
||||
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
|
||||
+ // CraftBukkit start
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ EntityType hatchingType = EntityType.CHICKEN;
|
||||
+
|
||||
+ Entity shooter = this.getOwner();
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ if (shooter instanceof EntityPlayer) {
|
||||
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
@@ -45,24 +45,27 @@
|
||||
+ b0 = event.getNumHatches();
|
||||
+ hatching = event.isHatching();
|
||||
+ hatchingType = event.getHatchingType();
|
||||
+ // If hatching is set to false, ensure child count is 0
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
for (int i = 0; i < b0; ++i) {
|
||||
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
|
||||
+ Entity entitychicken = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit
|
||||
|
||||
- if (entitychicken != null) {
|
||||
if (entitychicken != null) {
|
||||
- entitychicken.setAge(-24000);
|
||||
- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
|
||||
- this.level().addFreshEntity(entitychicken);
|
||||
+ if (hatching) {
|
||||
+ for (int i = 0; i < b0; ++i) {
|
||||
+ Entity entity = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass());
|
||||
+ if (entity != null) {
|
||||
+ if (entity.getBukkitEntity() instanceof Ageable) {
|
||||
+ ((Ageable) entity.getBukkitEntity()).setBaby();
|
||||
+ }
|
||||
+ this.level().getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
|
||||
+ // CraftBukkit start
|
||||
+ if (entitychicken.getBukkitEntity() instanceof Ageable) {
|
||||
+ ((Ageable) entitychicken.getBukkitEntity()).setBaby();
|
||||
+ }
|
||||
+ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 3);
|
||||
|
||||
Reference in New Issue
Block a user