2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityPotion.java
|
|
|
|
+++ b/net/minecraft/server/EntityPotion.java
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -7,6 +7,13 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
|
|
+import org.bukkit.entity.LivingEntity;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityPotion extends EntityProjectile {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Optional<ItemStack>> d = DataWatcher.a(EntityItem.class, DataWatcherRegistry.f);
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -78,10 +85,11 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
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
|
2016-05-10 13:47:39 +02:00
|
|
|
if (this.isLingering()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-03-12 18:12:25 +01:00
|
|
|
+ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit
|
2016-05-10 13:47:39 +02:00
|
|
|
entityareaeffectcloud.setSource(this.getShooter());
|
2016-03-12 18:12:25 +01:00
|
|
|
entityareaeffectcloud.setRadius(3.0F);
|
|
|
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -96,11 +104,21 @@
|
2016-03-12 18:12:25 +01:00
|
|
|
entityareaeffectcloud.a(new MobEffect(mobeffect.getMobEffect(), mobeffect.getDuration(), mobeffect.getAmplifier()));
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-03-12 18:12:25 +01:00
|
|
|
- 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 {
|
2016-02-29 22:32:46 +01:00
|
|
|
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>();
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!list1.isEmpty()) {
|
|
|
|
Iterator iterator1 = list1.iterator();
|
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -117,21 +135,45 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
d1 = 1.0D;
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- Iterator iterator2 = list.iterator();
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-03-20 03:42:12 +01:00
|
|
|
|
|
|
|
- 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()));
|
|
|
|
- }
|
|
|
|
- }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
|
|
|
|
+ double d1 = event.getIntensity(victim);
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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);
|
2016-03-20 03:42:12 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (i > 20) {
|
|
|
|
+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -139,10 +181,10 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-
|
|
|
|
- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
|
|
|
|
- this.die();
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
|
|
|
|
+ this.die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -152,6 +194,7 @@
|
2016-03-09 19:21:29 +01:00
|
|
|
|
|
|
|
private void a(BlockPosition blockposition) {
|
|
|
|
if (this.world.getType(blockposition).getBlock() == Blocks.FIRE) {
|
|
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) return; // CraftBukkit
|
|
|
|
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
|
|
|
|
}
|
|
|
|
|