--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java @@ -33,6 +33,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import net.minecraft.resources.MinecraftKey; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; +// CraftBukkit end + public class EntityAreaEffectCloud extends Entity { private static final Logger LOGGER = LogManager.getLogger(); @@ -124,6 +130,22 @@ } + // CraftBukkit start accessor methods + public void refreshEffects() { + if (!this.hasColor) { + this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename + } + } + + public String getType() { + return ((MinecraftKey) IRegistry.POTION.getKey(this.potionRegistry)).toString(); + } + + public void setType(String string) { + a(IRegistry.POTION.get(new MinecraftKey(string))); + } + // CraftBukkit end + public int getColor() { return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR); } @@ -268,6 +290,7 @@ if (!list1.isEmpty()) { Iterator iterator2 = list1.iterator(); + List entities = new java.util.ArrayList(); // CraftBukkit while (iterator2.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator2.next(); @@ -277,6 +300,17 @@ double d2 = d0 * d0 + d1 * d1; if (d2 <= (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.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay); Iterator iterator3 = list.iterator(); @@ -286,7 +320,7 @@ if (mobeffect1.getMobEffect().isInstant()) { mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D); } else { - entityliving.addEffect(new MobEffect(mobeffect1)); + entityliving.addEffect(new MobEffect(mobeffect1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit } }