aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch b/patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch
new file mode 100644
index 0000000000..1c26a1f3a3
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/entity/monster/EntitySlime.patch
@@ -0,0 +1,66 @@
+--- 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<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
+@@ -192,7 +200,7 @@
+
+ @Override
+ public EntityTypes<? extends EntitySlime> getType() {
+- return super.getType();
++ return (EntityTypes<? extends EntitySlime>) 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<EntityLiving> 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);