diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-24 22:53:23 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-10-27 22:19:03 -0400 |
commit | 60819c6693daf19dde68b04af38a4fee8c7da988 (patch) | |
tree | e7bd96a07f0e9d9f1f6b2721ddd1bb5dd71eaf48 /src/main/java/net/minecraft/server/EntityPotion.java | |
parent | b9a72531b6e2ccc84bd021bca421255a957d96f7 (diff) | |
download | craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.gz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.lz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.xz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.zip |
Update CraftBukkit to Minecraft 1.4(.2).
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityPotion.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityPotion.java | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java index 95b3454d..ed382160 100644 --- a/src/main/java/net/minecraft/server/EntityPotion.java +++ b/src/main/java/net/minecraft/server/EntityPotion.java @@ -12,41 +12,57 @@ import org.bukkit.entity.LivingEntity; public class EntityPotion extends EntityProjectile { - private int d; + private ItemStack d; 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.d = i; + this.d = itemstack; } - public EntityPotion(World world, double d0, double d1, double d2, int i) { + public EntityPotion(World world, double d0, double d1, double d2, ItemStack itemstack) { super(world, d0, d1, d2); - this.d = i; + this.d = itemstack; } - protected float h() { + protected float g() { return 0.05F; } - protected float d() { + protected float c() { return 0.5F; } - protected float g() { + protected float d() { return -20.0F; } + public void setPotionValue(int i) { + if (this.d == null) { + this.d = new ItemStack(Item.POTION, 1, 0); + } + + this.d.setData(i); + } + public int getPotionValue() { - return this.d; + if (this.d == null) { + this.d = new ItemStack(Item.POTION, 1, 0); + } + + return this.d.getData(); } protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isStatic) { - List list = Item.POTION.f(this.d); + List list = Item.POTION.l(this.d); if (list != null && !list.isEmpty()) { AxisAlignedBB axisalignedbb = this.boundingBox.grow(4.0D, 2.0D, 4.0D); @@ -114,18 +130,28 @@ public class EntityPotion extends EntityProjectile { } } - this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.d); + 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); - this.d = nbttagcompound.getInt("potionValue"); + if (nbttagcompound.hasKey("Potion")) { + this.d = ItemStack.a(nbttagcompound.getCompound("Potion")); + } else { + this.setPotionValue(nbttagcompound.getInt("potionValue")); + } + + if (this.d == null) { + this.die(); + } } public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); - nbttagcompound.setInt("potionValue", this.d); + if (this.d != null) { + nbttagcompound.setCompound("Potion", this.d.save(new NBTTagCompound())); + } } } |