1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
package net.minecraft.server;
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 {
private ItemStack c;
public EntityPotion(World world) {
super(world);
}
public EntityPotion(World world, EntityLiving entityliving, int i) {
this(world, entityliving, new ItemStack(Item.POTION, 1, i));
}
public EntityPotion(World world, EntityLiving entityliving, ItemStack itemstack) {
super(world, entityliving);
this.c = itemstack;
}
public EntityPotion(World world, double d0, double d1, double d2, ItemStack itemstack) {
super(world, d0, d1, d2);
this.c = itemstack;
}
protected float g() {
return 0.05F;
}
protected float c() {
return 0.5F;
}
protected float d() {
return -20.0F;
}
public void setPotionValue(int i) {
if (this.c == null) {
this.c = new ItemStack(Item.POTION, 1, 0);
}
this.c.setData(i);
}
public int getPotionValue() {
if (this.c == null) {
this.c = new ItemStack(Item.POTION, 1, 0);
}
return this.c.getData();
}
protected void a(MovingObjectPosition movingobjectposition) {
if (!this.world.isStatic) {
List list = Item.POTION.l(this.c);
if (list != null && !list.isEmpty()) {
AxisAlignedBB axisalignedbb = this.boundingBox.grow(4.0D, 2.0D, 4.0D);
List list1 = this.world.a(EntityLiving.class, axisalignedbb);
if (list1 != null && !list1.isEmpty()) {
Iterator iterator = list1.iterator();
// CraftBukkit
HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
while (iterator.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator.next();
double d0 = this.e(entityliving);
if (d0 < 16.0D) {
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
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()) {
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()) {
// CraftBukkit - added 'this'
MobEffectList.byId[i].applyInstantEffect(this.getShooter(), entityliving, mobeffect.getAmplifier(), d1, this);
} else {
int j = (int) (d1 * (double) mobeffect.getDuration() + 0.5D);
if (j > 20) {
entityliving.addEffect(new MobEffect(i, j, mobeffect.getAmplifier()));
}
}
}
}
}
}
}
this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.getPotionValue());
this.die();
}
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKey("Potion")) {
this.c = ItemStack.a(nbttagcompound.getCompound("Potion"));
} else {
this.setPotionValue(nbttagcompound.getInt("potionValue"));
}
if (this.c == null) {
this.die();
}
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
if (this.c != null) {
nbttagcompound.setCompound("Potion", this.c.save(new NBTTagCompound()));
}
}
}
|