2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/monster/EntitySlime.java
|
|
|
|
+++ b/net/minecraft/world/entity/monster/EntitySlime.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -43,6 +43,15 @@
|
|
|
|
import net.minecraft.world.level.levelgen.SeededRandom;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
2018-12-04 23:51:20 +01:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
2018-11-14 04:10:22 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2024-02-21 10:55:34 +01:00
|
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
2018-11-14 04:10:22 +01:00
|
|
|
+import org.bukkit.event.entity.EntityTransformEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.SlimeSplitEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -193,11 +202,18 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-11-21 23:00:00 +01:00
|
|
|
public EntityTypes<? extends EntitySlime> getType() {
|
|
|
|
- return super.getType();
|
|
|
|
+ return (EntityTypes<? extends EntitySlime>) super.getType(); // CraftBukkit - decompile error
|
2018-07-15 02:00:00 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2024-02-21 10:55:34 +01:00
|
|
|
public void remove(Entity.RemovalReason entity_removalreason) {
|
|
|
|
+ // CraftBukkit start - add Bukkit remove cause
|
|
|
|
+ this.remove(entity_removalreason, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
int i = this.getSize();
|
|
|
|
|
|
|
|
if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) {
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -208,6 +224,19 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
int j = i / 2;
|
|
|
|
int k = 2 + this.random.nextInt(3);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2020-06-25 02:00:00 +02:00
|
|
|
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (!event.isCancelled() && event.getCount() > 0) {
|
2020-06-25 02:00:00 +02:00
|
|
|
+ k = event.getCount();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
2024-02-21 10:55:34 +01:00
|
|
|
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
2018-12-04 23:51:20 +01:00
|
|
|
+ List<EntityLiving> slimes = new ArrayList<>(j);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
for (int l = 0; l < k; ++l) {
|
2024-04-23 17:15:00 +02:00
|
|
|
float f2 = ((float) (l % 2) - 0.5F) * f1;
|
|
|
|
float f3 = ((float) (l / 2) - 0.5F) * f1;
|
|
|
|
@@ -223,12 +252,21 @@
|
2022-12-07 17:00:00 +01:00
|
|
|
entityslime.setInvulnerable(this.isInvulnerable());
|
|
|
|
entityslime.setSize(j, true);
|
2024-04-23 17:15:00 +02:00
|
|
|
entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F);
|
2023-06-07 17:30:00 +02:00
|
|
|
- this.level().addFreshEntity(entityslime);
|
2022-12-07 17:00:00 +01:00
|
|
|
+ slimes.add(entityslime); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
2018-12-04 23:51:20 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
|
2024-02-21 10:55:34 +01:00
|
|
|
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
|
2018-12-04 23:51:20 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (EntityLiving living : slimes) {
|
2023-06-07 17:30:00 +02:00
|
|
|
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
|
2022-12-07 17:00:00 +01:00
|
|
|
+ }
|
2018-12-04 23:51:20 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2024-02-21 10:55:34 +01:00
|
|
|
- super.remove(entity_removalreason);
|
|
|
|
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|