--- a/net/minecraft/world/entity/monster/EntitySlime.java +++ b/net/minecraft/world/entity/monster/EntitySlime.java @@ -44,6 +44,14 @@ import net.minecraft.world.phys.Vec3D; import org.joml.Vector3f; +// CraftBukkit start +import java.util.ArrayList; +import java.util.List; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.SlimeSplitEvent; +// CraftBukkit end + public class EntitySlime extends EntityInsentient implements IMonster { private static final DataWatcherObject ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT); @@ -192,7 +200,7 @@ @Override public EntityTypes getType() { - return super.getType(); + return (EntityTypes) super.getType(); // CraftBukkit - decompile error } @Override @@ -206,6 +214,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); + // CraftBukkit start + SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k); + this.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled() && event.getCount() > 0) { + k = event.getCount(); + } else { + super.remove(entity_removalreason); + return; + } + List slimes = new ArrayList<>(j); + // CraftBukkit end + for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; @@ -221,9 +242,18 @@ entityslime.setInvulnerable(this.isInvulnerable()); entityslime.setSize(j, true); entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); - this.level().addFreshEntity(entityslime); + slimes.add(entityslime); // CraftBukkit } } + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { + super.remove(entity_removalreason); + return; + } + for (EntityLiving living : slimes) { + this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason + } + // CraftBukkit end } super.remove(entity_removalreason);