diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-11-29 21:22:35 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-11-29 21:22:35 +1100 |
commit | 2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1 (patch) | |
tree | 28525ae33fee47b70b749e0f22b4fef588846399 /src/main/java/net/minecraft/server | |
parent | a51eb9c3cac28dce1d4443e35f78460695ea97d4 (diff) | |
download | craftbukkit-2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1.tar craftbukkit-2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1.tar.gz craftbukkit-2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1.tar.lz craftbukkit-2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1.tar.xz craftbukkit-2759809ecba4e5f2d8c8ae51f5781a0c1a96b0c1.zip |
Fix Craft Entity constructors and toStrings.
Also, standardise getHandle and clean up in general.
getHandle is now using the 'entity' member variable instead of
super.getHandle, as this reduces the number of chained calls needed.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityMinecart.java | 35 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/EntityPotion.java | 87 |
2 files changed, 116 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 74aafbeb..ff9e9c69 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -12,6 +12,7 @@ import org.bukkit.event.vehicle.VehicleEnterEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleUpdateEvent; +import org.bukkit.util.Vector; // CraftBukkit end public class EntityMinecart extends Entity implements IInventory { @@ -32,12 +33,12 @@ public class EntityMinecart extends Entity implements IInventory { // CraftBukkit start public boolean slowWhenEmpty = true; - public double derailedX = 0.5; - public double derailedY = 0.5; - public double derailedZ = 0.5; - public double flyingX = 0.95; - public double flyingY = 0.95; - public double flyingZ = 0.95; + private double derailedX = 0.5; + private double derailedY = 0.5; + private double derailedZ = 0.5; + private double flyingX = 0.95; + private double flyingY = 0.95; + private double flyingZ = 0.95; public double maxSpeed = 0.4D; public ItemStack[] getContents() { @@ -934,4 +935,26 @@ public class EntityMinecart extends Entity implements IInventory { public int m() { return this.datawatcher.getInt(18); } + + // CraftBukkit start - methods for getting and setting flying and derailed velocity modifiers + public Vector getFlyingVelocityMod() { + return new Vector(flyingX, flyingY, flyingZ); + } + + public void setFlyingVelocityMod(Vector flying) { + flyingX = flying.getX(); + flyingY = flying.getY(); + flyingZ = flying.getZ(); + } + + public Vector getDerailedVelocityMod() { + return new Vector(derailedX, derailedY, derailedZ); + } + + public void setDerailedVelocityMod(Vector derailed) { + derailedX = derailed.getX(); + derailedY = derailed.getY(); + derailedZ = derailed.getZ(); + } + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java new file mode 100644 index 00000000..41247f51 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityPotion.java @@ -0,0 +1,87 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.List; + +public class EntityPotion extends EntityProjectile { + + private int d; + + public EntityPotion(World world) { + super(world); + } + + public EntityPotion(World world, EntityLiving entityliving, int i) { + super(world, entityliving); + this.d = i; + } + + public EntityPotion(World world, double d0, double d1, double d2, int i) { + super(world, d0, d1, d2); + this.d = i; + } + + protected float e() { + return 0.05F; + } + + protected float c() { + return 0.5F; + } + + protected float d() { + return -20.0F; + } + + public int f() { + return this.d; + } + + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + List list = Item.POTION.b(this.d); + + if (list != null && !list.isEmpty()) { + AxisAlignedBB axisalignedbb = this.boundingBox.b(4.0D, 2.0D, 4.0D); + List list1 = this.world.a(EntityLiving.class, axisalignedbb); + + if (list1 != null && !list1.isEmpty()) { + Iterator iterator = list1.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + double d0 = this.i(entity); + + if (d0 < 16.0D) { + double d1 = 1.0D - Math.sqrt(d0) / 4.0D; + + if (entity == movingobjectposition.entity) { + d1 = 1.0D; + } + + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator1.next(); + int i = mobeffect.getEffectId(); + + if (MobEffectList.byId[i].b()) { + MobEffectList.byId[i].a(this.shooter, (EntityLiving) entity, mobeffect.getAmplifier(), d1); + } else { + int j = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); + + if (j > 20) { + ((EntityLiving) entity).addEffect(new MobEffect(i, j, mobeffect.getAmplifier())); + } + } + } + } + } + } + } + + this.world.f(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.d); + this.die(); + } + } +} |