summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityPotion.patch
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/EntityPotion.patch
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/EntityPotion.patch')
-rw-r--r--nms-patches/EntityPotion.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch
new file mode 100644
index 00000000..fd9e7d33
--- /dev/null
+++ b/nms-patches/EntityPotion.patch
@@ -0,0 +1,70 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/EntityPotion.java 2014-11-27 08:59:46.721421758 +1100
++++ src/main/java/net/minecraft/server/EntityPotion.java 2014-11-27 08:42:10.112850989 +1100
+@@ -3,6 +3,13 @@
+ import java.util.Iterator;
+ import java.util.List;
+
++// CraftBukkit start
++import java.util.HashMap;
++
++import org.bukkit.craftbukkit.entity.CraftLivingEntity;
++import org.bukkit.entity.LivingEntity;
++// CraftBukkit end
++
+ public class EntityPotion extends EntityProjectile {
+
+ public ItemStack item;
+@@ -57,12 +64,15 @@
+ if (!this.world.isStatic) {
+ List list = Items.POTION.h(this.item);
+
+- if (list != null && !list.isEmpty()) {
++ if (true || list != null && !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
+ AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
+ List list1 = this.world.a(EntityLiving.class, axisalignedbb);
+
+- if (!list1.isEmpty()) {
++ if (true || !list1.isEmpty()) { // CraftBukkit - Run code even if there are no entities around
+ Iterator iterator = list1.iterator();
++
++ // CraftBukkit
++ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
+
+ while (iterator.hasNext()) {
+ EntityLiving entityliving = (EntityLiving) iterator.next();
+@@ -74,12 +84,35 @@
+ if (entityliving == movingobjectposition.entity) {
+ d1 = 1.0D;
+ }
++
++ // 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;
++ }
++
++ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
++ double d1 = event.getIntensity(victim);
++ // CraftBukkit end
+
+ Iterator iterator1 = list.iterator();
+
+ while (iterator1.hasNext()) {
+ MobEffect mobeffect = (MobEffect) iterator1.next();
+ int i = mobeffect.getEffectId();
++
++ // CraftBukkit start - Abide by PVP settings - for players only!
++ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) {
++ // 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.byId[i].isInstant()) {
+ MobEffectList.byId[i].applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1);