From b3f6de0da51ba476bb6792f6fdf44cec472d3cce Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 12 Mar 2016 12:12:25 -0500 Subject: SPIGOT-1904: AreaEffectCloud events and additional API --- nms-patches/EntityAreaEffectCloud.patch | 39 ++++++++++++++++++++++++++++++++- nms-patches/EntityPotion.patch | 31 ++++++++++++++++---------- 2 files changed, 58 insertions(+), 12 deletions(-) (limited to 'nms-patches') diff --git a/nms-patches/EntityAreaEffectCloud.patch b/nms-patches/EntityAreaEffectCloud.patch index 0be2ccd8..08cb2e41 100644 --- a/nms-patches/EntityAreaEffectCloud.patch +++ b/nms-patches/EntityAreaEffectCloud.patch @@ -1,6 +1,17 @@ --- a/net/minecraft/server/EntityAreaEffectCloud.java +++ b/net/minecraft/server/EntityAreaEffectCloud.java -@@ -91,6 +91,22 @@ +@@ -8,6 +8,10 @@ + import java.util.List; + import java.util.Map; + import java.util.UUID; ++ ++import org.bukkit.craftbukkit.entity.CraftLivingEntity; // CraftBukkit ++import org.bukkit.entity.LivingEntity; // CraftBukkit ++ + import java.util.Map.Entry; + + public class EntityAreaEffectCloud extends Entity { +@@ -91,6 +95,22 @@ } @@ -23,3 +34,29 @@ public int getColor() { return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.b)).intValue(); } +@@ -237,6 +257,7 @@ + if (!list.isEmpty()) { + Iterator iterator2 = list.iterator(); + ++ List entities = new ArrayList(); // CraftBukkit + while (iterator2.hasNext()) { + EntityLiving entityliving = (EntityLiving) iterator2.next(); + +@@ -246,6 +267,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 (true) { // Preserve NMS spacing and bracket count for smallest diff ++ for (LivingEntity entity : event.getAffectedEntities()) { ++ if (entity instanceof CraftLivingEntity) { ++ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); ++ // CraftBukkit end + this.g.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay)); + Iterator iterator3 = arraylist.iterator(); + diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch index f4731684..e7574eba 100644 --- a/nms-patches/EntityPotion.patch +++ b/nms-patches/EntityPotion.patch @@ -14,7 +14,7 @@ public class EntityPotion extends EntityProjectile { private static final DataWatcherObject> d = DataWatcher.a(EntityItem.class, DataWatcherRegistry.f); -@@ -77,7 +84,7 @@ +@@ -77,10 +84,11 @@ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry)); this.die(); } else { @@ -23,15 +23,24 @@ if (this.n()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ); -@@ -89,6 +96,7 @@ - entityareaeffectcloud.a(potionregistry); - iterator = PotionUtil.b(itemstack).iterator(); - -+ // PAIL: Add events - while (iterator.hasNext()) { - MobEffect mobeffect = (MobEffect) iterator.next(); ++ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit + entityareaeffectcloud.a(this.getShooter()); + entityareaeffectcloud.setRadius(3.0F); + entityareaeffectcloud.setRadiusOnUse(-0.5F); +@@ -95,11 +103,21 @@ + entityareaeffectcloud.a(new MobEffect(mobeffect.getMobEffect(), mobeffect.getDuration(), mobeffect.getAmplifier())); + } -@@ -100,6 +108,9 @@ +- this.world.addEntity(entityareaeffectcloud); ++ // CraftBukkit start ++ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); ++ if (!(event.isCancelled() || entityareaeffectcloud.dead)) { ++ this.world.addEntity(entityareaeffectcloud); ++ } else { ++ entityareaeffectcloud.dead = true; ++ } ++ // CraftBukkit end + } else { AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); List list1 = this.world.a(EntityLiving.class, axisalignedbb); @@ -41,7 +50,7 @@ if (!list1.isEmpty()) { Iterator iterator1 = list1.iterator(); -@@ -116,21 +127,45 @@ +@@ -116,21 +134,45 @@ d1 = 1.0D; } @@ -101,7 +110,7 @@ } } } -@@ -138,19 +173,20 @@ +@@ -138,19 +180,20 @@ } } } -- cgit v1.2.3