diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Slime.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Slime.java.patch | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Slime.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Slime.java.patch new file mode 100644 index 0000000000..e937d8eaea --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Slime.java.patch @@ -0,0 +1,85 @@ +--- a/net/minecraft/world/entity/monster/Slime.java ++++ b/net/minecraft/world/entity/monster/Slime.java +@@ -44,7 +44,16 @@ + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + +-public class Slime extends Mob implements Enemy { ++// 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 Slime extends Mob implements IMonster { ++ + private static final EntityDataAccessor<Integer> ID_SIZE = SynchedEntityData.defineId(Slime.class, EntityDataSerializers.INT); + public static final int MIN_SIZE = 1; + public static final int MAX_SIZE = 127; +@@ -202,23 +207,53 @@ + int i = size / 2; + int i1 = 2 + this.random.nextInt(3); + +- for (int i2 = 0; i2 < i1; i2++) { +- float f1 = ((float)(i2 % 2) - 0.5F) * f; +- float f2 = ((float)(i2 / 2) - 0.5F) * f; +- Slime slime = this.getType().create(this.level()); +- if (slime != null) { ++ if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) { ++ Component ichatbasecomponent = this.getCustomName(); ++ boolean flag = this.isNoAi(); ++ float f = (float) i / 4.0F; ++ 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(reason); ++ return; ++ } ++ List<LivingEntity> 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; ++ Slime entityslime = (Slime) this.getType().create(this.level()); ++ ++ if (entityslime != null) { + if (this.isPersistenceRequired()) { + slime.setPersistenceRequired(); + } + +- slime.setCustomName(customName); +- slime.setNoAi(isNoAi); +- slime.setInvulnerable(this.isInvulnerable()); +- slime.setSize(i, true); +- slime.moveTo(this.getX() + (double)f1, this.getY() + 0.5, this.getZ() + (double)f2, this.random.nextFloat() * 360.0F, 0.0F); +- this.level().addFreshEntity(slime); ++ entityslime.setCustomName(ichatbasecomponent); ++ entityslime.setNoAi(flag); ++ 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); ++ slimes.add(entityslime); // CraftBukkit + } + } ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { ++ super.remove(reason); ++ return; ++ } ++ for (LivingEntity living : slimes) { ++ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason ++ } ++ // CraftBukkit end + } + + super.remove(reason); |