@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/server/EntityPotion.java
|
||||
+++ b/net/minecraft/server/EntityPotion.java
|
||||
@@ -3,6 +3,13 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -6,6 +6,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.HashMap;
|
||||
@@ -13,59 +13,105 @@
|
||||
+
|
||||
public class EntityPotion extends EntityProjectile {
|
||||
|
||||
public ItemStack item;
|
||||
@@ -57,13 +64,16 @@
|
||||
if (!this.world.isClientSide) {
|
||||
List list = Items.POTION.h(this.item);
|
||||
private static final DataWatcherObject<Optional<ItemStack>> d = DataWatcher.a(EntityItem.class, DataWatcherRegistry.f);
|
||||
@@ -77,7 +84,7 @@
|
||||
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.n()) {
|
||||
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
|
||||
|
||||
- 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);
|
||||
@@ -89,6 +96,7 @@
|
||||
entityareaeffectcloud.a(potionregistry);
|
||||
iterator = PotionUtil.b(itemstack).iterator();
|
||||
|
||||
- if (!list1.isEmpty()) {
|
||||
+ if (true || !list1.isEmpty()) { // CraftBukkit - Run code even if there are no entities around
|
||||
Iterator iterator = list1.iterator();
|
||||
+ // PAIL: Add events
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
+ // CraftBukkit
|
||||
+ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
|
||||
@@ -100,6 +108,9 @@
|
||||
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>();
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
EntityLiving entityliving = (EntityLiving) iterator.next();
|
||||
double d0 = this.h(entityliving);
|
||||
@@ -75,12 +85,35 @@
|
||||
d1 = 1.0D;
|
||||
}
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator1 = list1.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;
|
||||
+ }
|
||||
+
|
||||
+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
|
||||
+ double d1 = event.getIntensity(victim);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
Iterator iterator1 = list.iterator();
|
||||
@@ -116,21 +127,45 @@
|
||||
d1 = 1.0D;
|
||||
}
|
||||
|
||||
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;
|
||||
- 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;
|
||||
+ }
|
||||
+
|
||||
+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
|
||||
+ double d1 = event.getIntensity(victim);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (MobEffectList.byId[i].isInstant()) {
|
||||
MobEffectList.byId[i].applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1);
|
||||
} else {
|
||||
+ Iterator iterator2 = list.iterator();
|
||||
+
|
||||
+ 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);
|
||||
|
||||
- while (iterator2.hasNext()) {
|
||||
- MobEffect mobeffect1 = (MobEffect) iterator2.next();
|
||||
- MobEffectList mobeffectlist = mobeffect1.getMobEffect();
|
||||
-
|
||||
- if (mobeffectlist.isInstant()) {
|
||||
- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1);
|
||||
- } else {
|
||||
- int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D);
|
||||
-
|
||||
- if (i > 20) {
|
||||
- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
|
||||
- }
|
||||
- }
|
||||
+ if (i > 20) {
|
||||
+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +173,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
|
||||
- this.die();
|
||||
}
|
||||
+
|
||||
+ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
|
||||
+ this.die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user