diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-11-20 00:01:14 -0800 |
---|---|---|
committer | Erik Broes <erikbroes@ripe.net> | 2011-11-20 00:01:33 -0800 |
commit | 345ea36c7bb3383c6e4825355d0043a646194eaa (patch) | |
tree | df116b57d92315c0a13c2fdc87d792b031c7239a /src/main/java/net/minecraft/server/EntityFireball.java | |
parent | 589f66bd1b766dc1fdd737ee885304196a2ed86a (diff) | |
download | craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.gz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.lz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.tar.xz craftbukkit-345ea36c7bb3383c6e4825355d0043a646194eaa.zip |
Update for 1.0.0
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityFireball.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityFireball.java | 173 |
1 files changed, 94 insertions, 79 deletions
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 99937ae9..32ec99a2 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -15,15 +15,14 @@ import org.bukkit.event.entity.ProjectileHitEvent; public class EntityFireball extends Entity { + private int e = -1; private int f = -1; private int g = -1; - private int h = -1; - private int i = 0; - private boolean j = false; - public int a = 0; + private int h = 0; + private boolean i = false; public EntityLiving shooter; - private int k; - private int l = 0; + private int j; + private int k = 0; public double dirX; public double dirY; public double dirZ; @@ -61,33 +60,33 @@ public class EntityFireball extends Entity { this.dirZ = d2 / d3 * 0.1D; } - public void s_() { - super.s_(); - this.fireTicks = 10; - if (this.a > 0) { - --this.a; + public void w_() { + super.w_(); + this.j(1); + if (!this.world.isStatic && (this.shooter == null || this.shooter.dead)) { + this.die(); } - if (this.j) { - int i = this.world.getTypeId(this.f, this.g, this.h); + if (this.i) { + int i = this.world.getTypeId(this.e, this.f, this.g); - if (i == this.i) { - ++this.k; - if (this.k == 1200) { + if (i == this.h) { + ++this.j; + if (this.j == 1200) { this.die(); } return; } - this.j = false; + this.i = false; this.motX *= (double) (this.random.nextFloat() * 0.2F); this.motY *= (double) (this.random.nextFloat() * 0.2F); this.motZ *= (double) (this.random.nextFloat() * 0.2F); + this.j = 0; this.k = 0; - this.l = 0; } else { - ++this.l; + ++this.k; } Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ); @@ -107,7 +106,7 @@ public class EntityFireball extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.r_() && (entity1 != this.shooter || this.l >= 25)) { + if (entity1.e_() && (!entity1.a((Entity) this.shooter) || this.k >= 25)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); @@ -128,49 +127,6 @@ public class EntityFireball extends Entity { } if (movingobjectposition != null) { - // CraftBukkit start - ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(phe); - // CraftBukkit end - if (!this.world.isStatic) { - // CraftBukkit start - if (movingobjectposition.entity != null) { - boolean stick; - if (movingobjectposition.entity instanceof EntityLiving) { - org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); - Projectile projectile = (Projectile) this.getBukkitEntity(); - - // TODO @see EntityArrow#162 - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); - - this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); - - if (event.isCancelled()) { - stick = !projectile.doesBounce(); - } else { - // this function returns if the fireball should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage()); - } - } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 0); - } - if (stick) { - ; - } - } - - ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this)); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - // give 'this' instead of (Entity) null so we know what causes the damage - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); - } - // CraftBukkit end - } - - this.die(); } this.locX += this.motX; @@ -200,7 +156,7 @@ public class EntityFireball extends Entity { this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; float f2 = 0.95F; - if (this.ao()) { + if (this.az()) { for (int k = 0; k < 4; ++k) { float f3 = 0.25F; @@ -220,32 +176,83 @@ public class EntityFireball extends Entity { this.setPosition(this.locX, this.locY, this.locZ); } + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + // CraftBukkit end + if (!this.world.isStatic) { + // CraftBukkit start + if (movingobjectposition.entity != null) { + boolean stick; + if (movingobjectposition.entity instanceof EntityLiving) { + org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); + Projectile projectile = (Projectile) this.getBukkitEntity(); + + // TODO @see EntityArrow#162 + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); + this.world.getServer().getPluginManager().callEvent(event); + + this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); + + if (event.isCancelled()) { + stick = !projectile.doesBounce(); + } else { + // this function returns if the fireball should stick in or not, i.e. !bounce + stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage()); + } + } else { + stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 0); + } + if (stick) { + ; + } + } + + ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this)); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + } + // CraftBukkit end + } + + // this.world.createExplosion((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true); // CraftBukkit + this.die(); + } + } + public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("xTile", (short) this.f); - nbttagcompound.a("yTile", (short) this.g); - nbttagcompound.a("zTile", (short) this.h); - nbttagcompound.a("inTile", (byte) this.i); - nbttagcompound.a("shake", (byte) this.a); - nbttagcompound.a("inGround", (byte) (this.j ? 1 : 0)); + nbttagcompound.a("xTile", (short) this.e); + nbttagcompound.a("yTile", (short) this.f); + nbttagcompound.a("zTile", (short) this.g); + nbttagcompound.a("inTile", (byte) this.h); + nbttagcompound.a("inGround", (byte) (this.i ? 1 : 0)); } public void a(NBTTagCompound nbttagcompound) { - this.f = nbttagcompound.d("xTile"); - this.g = nbttagcompound.d("yTile"); - this.h = nbttagcompound.d("zTile"); - this.i = nbttagcompound.c("inTile") & 255; - this.a = nbttagcompound.c("shake") & 255; - this.j = nbttagcompound.c("inGround") == 1; + this.e = nbttagcompound.e("xTile"); + this.f = nbttagcompound.e("yTile"); + this.g = nbttagcompound.e("zTile"); + this.h = nbttagcompound.d("inTile") & 255; + this.i = nbttagcompound.d("inGround") == 1; } - public boolean r_() { + public boolean e_() { return true; } + public float j_() { + return 1.0F; + } + public boolean damageEntity(DamageSource damagesource, int i) { - this.aq(); + this.aB(); if (damagesource.getEntity() != null) { - Vec3D vec3d = damagesource.getEntity().ai(); + Vec3D vec3d = damagesource.getEntity().ap(); if (vec3d != null) { this.motX = vec3d.a; @@ -256,9 +263,17 @@ public class EntityFireball extends Entity { this.dirZ = this.motZ * 0.1D; } + if (damagesource.getEntity() instanceof EntityLiving) { + this.shooter = (EntityLiving) damagesource.getEntity(); + } + return true; } else { return false; } } + + public float a(float f) { + return 1.0F; + } } |