2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntitySlime.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntitySlime.java
|
2022-06-08 02:00:00 +10:00
|
|
|
@@ -42,6 +42,14 @@
|
|
|
|
import net.minecraft.world.level.levelgen.SeededRandom;
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2021-03-09 08:47:33 +11:00
|
|
|
|
2014-11-26 08:32:16 +11:00
|
|
|
+// CraftBukkit start
|
2018-12-05 09:51:20 +11:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
2018-11-14 14:10:22 +11:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
2014-11-26 08:32:16 +11:00
|
|
|
+import org.bukkit.event.entity.SlimeSplitEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-09 08:47:33 +11:00
|
|
|
+
|
2014-11-26 08:32:16 +11:00
|
|
|
public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -185,7 +193,7 @@
|
2018-07-15 10:00:00 +10:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
2021-11-22 09:00:00 +11:00
|
|
|
public EntityTypes<? extends EntitySlime> getType() {
|
|
|
|
- return super.getType();
|
|
|
|
+ return (EntityTypes<? extends EntitySlime>) super.getType(); // CraftBukkit - decompile error
|
2018-07-15 10:00:00 +10:00
|
|
|
}
|
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
@Override
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -199,6 +207,19 @@
|
2020-06-25 10:00:00 +10:00
|
|
|
int j = i / 2;
|
|
|
|
int k = 2 + this.random.nextInt(3);
|
2015-02-26 22:41:06 +00:00
|
|
|
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit start
|
2020-06-25 10:00:00 +10:00
|
|
|
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
|
2023-06-08 01:30:00 +10:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
2014-11-26 08:32:16 +11:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled() && event.getCount() > 0) {
|
2020-06-25 10:00:00 +10:00
|
|
|
+ k = event.getCount();
|
2014-11-26 08:32:16 +11:00
|
|
|
+ } else {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ super.remove(entity_removalreason);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-05 09:51:20 +11:00
|
|
|
+ List<EntityLiving> slimes = new ArrayList<>(j);
|
2014-11-26 08:32:16 +11:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 22:41:06 +00:00
|
|
|
+
|
2020-06-25 10:00:00 +10:00
|
|
|
for (int l = 0; l < k; ++l) {
|
|
|
|
float f1 = ((float) (l % 2) - 0.5F) * f;
|
|
|
|
float f2 = ((float) (l / 2) - 0.5F) * f;
|
2022-12-08 03:00:00 +11:00
|
|
|
@@ -214,9 +235,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);
|
2023-06-08 01:30:00 +10:00
|
|
|
- this.level().addFreshEntity(entityslime);
|
2022-12-08 03:00:00 +11:00
|
|
|
+ slimes.add(entityslime); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
2018-12-05 09:51:20 +11:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
|
2021-11-22 09:00:00 +11:00
|
|
|
+ super.remove(entity_removalreason);
|
2018-12-05 09:51:20 +11:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (EntityLiving living : slimes) {
|
2023-06-08 01:30:00 +10:00
|
|
|
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
|
2022-12-08 03:00:00 +11:00
|
|
|
+ }
|
2018-12-05 09:51:20 +11:00
|
|
|
+ // CraftBukkit end
|
2014-11-26 08:32:16 +11:00
|
|
|
}
|
|
|
|
|
2021-11-22 09:00:00 +11:00
|
|
|
super.remove(entity_removalreason);
|