PaperMC/paper-server/nms-patches/net/minecraft/world/entity/EntityAreaEffectCloud.patch
CraftBukkit/Spigot eed041d629 Update to Minecraft 1.21
By: md_5 <git@md-5.net>
2024-06-14 01:05:00 +10:00

93 lines
5.1 KiB
Diff

--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
@@ -32,6 +32,12 @@
import net.minecraft.world.level.material.EnumPistonReaction;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -188,7 +194,7 @@
}
} else {
if (this.tickCount >= this.waitTime + this.duration) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -205,7 +211,7 @@
if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -239,11 +245,12 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
- Stream stream = list.stream();
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) {
@@ -252,6 +259,19 @@
double d5 = d3 * d3 + d4 * d4;
if (d5 <= (double) (f * f)) {
+ // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
+ }
+ }
+ }
+ }
+ {
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (!event.isCancelled()) {
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -261,14 +281,14 @@
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) {
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- entityliving.addEffect(new MobEffect(mobeffect1), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}
if (this.radiusOnUse != 0.0F) {
f += this.radiusOnUse;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -278,7 +298,7 @@
if (this.durationOnUse != 0) {
this.duration += this.durationOnUse;
if (this.duration <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
}