summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityPotion.patch
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-11-17 12:41:03 +1100
committermd_5 <git@md-5.net>2016-11-17 12:41:03 +1100
commitc25ddf063a808e3adb749e22017661f403c5fb7e (patch)
treeb2efcff512be12fd3e38cf8c36386148ce6ab4ae /nms-patches/EntityPotion.patch
parent51263e97187a84338f89698eef187284055a682a (diff)
downloadcraftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.gz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.lz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.xz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.zip
Update to Minecraft 1.11
Diffstat (limited to 'nms-patches/EntityPotion.patch')
-rw-r--r--nms-patches/EntityPotion.patch193
1 files changed, 88 insertions, 105 deletions
diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch
index ef720315..ccef405f 100644
--- a/nms-patches/EntityPotion.patch
+++ b/nms-patches/EntityPotion.patch
@@ -1,134 +1,117 @@
--- a/net/minecraft/server/EntityPotion.java
+++ b/net/minecraft/server/EntityPotion.java
-@@ -7,6 +7,13 @@
+@@ -6,6 +6,12 @@
+ import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-
+// CraftBukkit start
+import java.util.HashMap;
-+
++import java.util.Map;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+// CraftBukkit end
-+
+
public class EntityPotion extends EntityProjectile {
- private static final DataWatcherObject<Optional<ItemStack>> d = DataWatcher.a(EntityPotion.class, DataWatcherRegistry.f);
-@@ -78,10 +85,11 @@
- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
- this.die();
- } else {
-- if (!list.isEmpty()) {
-+ if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
- if (this.isLingering()) {
- EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
+@@ -87,7 +93,7 @@
+
+ if (flag) {
+ this.n();
+- } else if (!list.isEmpty()) {
++ } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
+ if (this.isLingering()) {
+ this.a(itemstack, potionregistry);
+ } else {
+@@ -124,6 +130,7 @@
+ private void a(MovingObjectPosition movingobjectposition, List<MobEffect> list) {
+ AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
+ List list1 = this.world.a(EntityLiving.class, axisalignedbb);
++ Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
-+ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit
- entityareaeffectcloud.setSource(this.getShooter());
- entityareaeffectcloud.setRadius(3.0F);
- entityareaeffectcloud.setRadiusOnUse(-0.5F);
-@@ -96,11 +104,21 @@
- entityareaeffectcloud.a(new MobEffect(mobeffect.getMobEffect(), mobeffect.getDuration(), mobeffect.getAmplifier()));
+ if (!list1.isEmpty()) {
+ Iterator iterator = list1.iterator();
+@@ -141,21 +148,46 @@
+ d1 = 1.0D;
}
-- this.world.addEntity(entityareaeffectcloud);
+- Iterator iterator1 = list.iterator();
+ // 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);
-
-+ // CraftBukkit
-+ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
++ }
++ }
++ }
++ }
+
- if (!list1.isEmpty()) {
- Iterator iterator1 = list1.iterator();
-
-@@ -117,21 +135,45 @@
- d1 = 1.0D;
- }
-
-- Iterator iterator2 = list.iterator();
-+ // CraftBukkit start
-+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
-+ }
-+ }
-+ }
-+ }
++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected);
++ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process
++ for (LivingEntity victim : event.getAffectedEntities()) {
++ if (!(victim instanceof CraftLivingEntity)) {
++ continue;
++ }
-- while (iterator2.hasNext()) {
-- MobEffect mobeffect1 = (MobEffect) iterator2.next();
-- MobEffectList mobeffectlist = mobeffect1.getMobEffect();
+- while (iterator1.hasNext()) {
+- MobEffect mobeffect = (MobEffect) iterator1.next();
+- MobEffectList mobeffectlist = mobeffect.getMobEffect();
-
-- if (mobeffectlist.isInstant()) {
-- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1);
-- } else {
-- int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D);
+- if (mobeffectlist.isInstant()) {
+- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1);
+- } else {
+- int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D);
-
-- if (i > 20) {
-- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
-- }
-- }
-+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected);
-+ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process
-+ for (LivingEntity victim : event.getAffectedEntities()) {
-+ if (!(victim instanceof CraftLivingEntity)) {
-+ continue;
-+ }
+- if (i > 20) {
+- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()));
+- }
+- }
++ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
++ double d1 = event.getIntensity(victim);
++ // CraftBukkit end
+
-+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
-+ double d1 = event.getIntensity(victim);
-+ // CraftBukkit end
++ Iterator iterator1 = list.iterator();
+
-+ Iterator iterator2 = list.iterator();
++ while (iterator1.hasNext()) {
++ MobEffect mobeffect = (MobEffect) iterator1.next();
++ MobEffectList mobeffectlist = mobeffect.getMobEffect();
++ // CraftBukkit start - Abide by PVP settings - for players only!
++ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) {
++ int i = MobEffectList.getId(mobeffectlist);
++ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
++ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) {
++ continue;
++ }
++ }
++ // CraftBukkit end
+
-+ while (iterator2.hasNext()) {
-+ MobEffect mobeffect1 = (MobEffect) iterator2.next();
-+ MobEffectList mobeffectlist = mobeffect1.getMobEffect();
-+ // CraftBukkit start - Abide by PVP settings - for players only!
-+ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) {
-+ int i = MobEffectList.getId(mobeffectlist);
-+ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
-+ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) {
-+ continue;
-+ }
-+ }
-+ // CraftBukkit end
-+ if (mobeffectlist.isInstant()) {
-+ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1);
-+ } else {
-+ int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D);
++ if (mobeffectlist.isInstant()) {
++ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1);
++ } else {
++ int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D);
+
-+ if (i > 20) {
-+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
- }
- }
- }
-@@ -139,10 +181,10 @@
++ if (i > 20) {
++ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles()));
}
}
}
--
-- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
-- this.die();
- }
-+
-+ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
-+ this.die();
- }
- }
-
-@@ -152,6 +194,7 @@
+@@ -167,6 +199,7 @@
+ private void a(ItemStack itemstack, PotionRegistry potionregistry) {
+ EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
- private void a(BlockPosition blockposition) {
- if (this.world.getType(blockposition).getBlock() == Blocks.FIRE) {
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) return; // CraftBukkit
- this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
++ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit
+ entityareaeffectcloud.setSource(this.getShooter());
+ entityareaeffectcloud.setRadius(3.0F);
+ entityareaeffectcloud.setRadiusOnUse(-0.5F);
+@@ -181,7 +214,14 @@
+ entityareaeffectcloud.a(new MobEffect(mobeffect));
}
+- 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
+ }
+
+ public boolean isLingering() {