2011-02-04 04:03:11 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-02-04 04:03:11 +01:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
2011-03-18 22:57:22 +01:00
|
|
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.event.entity.CreeperPowerEvent;
|
2011-02-04 04:03:11 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public class EntityCreeper extends EntityMonster {
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
int fuseTicks;
|
2011-02-04 04:03:11 +01:00
|
|
|
int b;
|
|
|
|
|
|
|
|
public EntityCreeper(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/creeper.png";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public int getMaxHealth() {
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void b() {
|
|
|
|
super.b();
|
2011-02-04 04:03:11 +01:00
|
|
|
this.datawatcher.a(16, Byte.valueOf((byte) -1));
|
2011-04-20 22:47:26 +02:00
|
|
|
this.datawatcher.a(17, Byte.valueOf((byte) 0));
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
2011-09-24 23:03:31 +02:00
|
|
|
if (this.datawatcher.getByte(17) == 1) {
|
2011-11-30 00:17:43 +01:00
|
|
|
nbttagcompound.setBoolean("powered", true);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.datawatcher.watch(17, Byte.valueOf((byte) (nbttagcompound.getBoolean("powered") ? 1 : 0)));
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
protected void b(Entity entity, float f) {
|
2011-05-28 22:50:08 +02:00
|
|
|
if (!this.world.isStatic) {
|
|
|
|
if (this.fuseTicks > 0) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.b(-1);
|
2011-05-28 22:50:08 +02:00
|
|
|
--this.fuseTicks;
|
|
|
|
if (this.fuseTicks < 0) {
|
|
|
|
this.fuseTicks = 0;
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void w_() {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.b = this.fuseTicks;
|
2011-02-04 04:03:11 +01:00
|
|
|
if (this.world.isStatic) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int i = this.A();
|
2011-02-04 04:03:11 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (i > 0 && this.fuseTicks == 0) {
|
|
|
|
this.world.makeSound(this, "random.fuse", 1.0F, 0.5F);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.fuseTicks += i;
|
|
|
|
if (this.fuseTicks < 0) {
|
|
|
|
this.fuseTicks = 0;
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.fuseTicks >= 30) {
|
|
|
|
this.fuseTicks = 30;
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
super.w_();
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.target == null && this.fuseTicks > 0) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.b(-1);
|
2011-05-26 14:48:22 +02:00
|
|
|
--this.fuseTicks;
|
|
|
|
if (this.fuseTicks < 0) {
|
|
|
|
this.fuseTicks = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String m() {
|
2011-02-04 04:03:11 +01:00
|
|
|
return "mob.creeper";
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected String n() {
|
2011-02-04 04:03:11 +01:00
|
|
|
return "mob.creeperdeath";
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public void die(DamageSource damagesource) {
|
|
|
|
super.die(damagesource);
|
2011-09-15 18:36:27 +02:00
|
|
|
if (damagesource.getEntity() instanceof EntitySkeleton) {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.b(Item.RECORD_1.id + this.random.nextInt(2), 1);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(Entity entity, float f) {
|
2011-05-28 22:50:08 +02:00
|
|
|
if (!this.world.isStatic) {
|
2011-11-20 09:01:14 +01:00
|
|
|
int i = this.A();
|
2011-02-04 04:03:11 +01:00
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.b(-1);
|
2011-05-28 22:50:08 +02:00
|
|
|
--this.fuseTicks;
|
|
|
|
if (this.fuseTicks < 0) {
|
|
|
|
this.fuseTicks = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.fuseTicks == 0) {
|
|
|
|
this.world.makeSound(this, "random.fuse", 1.0F, 0.5F);
|
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
this.b(1);
|
2011-05-28 22:50:08 +02:00
|
|
|
++this.fuseTicks;
|
|
|
|
if (this.fuseTicks >= 30) {
|
|
|
|
// CraftBukkit start
|
2011-06-27 00:25:01 +02:00
|
|
|
float radius = this.isPowered() ? 6.0F : 3.0F;
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(this.world.getServer(), this), radius, false);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (!event.isCancelled()) {
|
|
|
|
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
|
|
|
|
this.die();
|
|
|
|
} else {
|
|
|
|
this.fuseTicks = 0;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
this.e = true;
|
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public boolean isPowered() {
|
2011-09-24 23:03:31 +02:00
|
|
|
return this.datawatcher.getByte(17) == 1;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected int e() {
|
2011-02-04 04:03:11 +01:00
|
|
|
return Item.SULPHUR.id;
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private int A() {
|
2011-09-24 23:03:31 +02:00
|
|
|
return this.datawatcher.getByte(16);
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
private void b(int i) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) i));
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void a(EntityWeatherLighting entityweatherlighting) {
|
|
|
|
super.a(entityweatherlighting);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-04-26 01:47:25 +02:00
|
|
|
// CraftBukkit start
|
2011-11-30 00:17:43 +01:00
|
|
|
CreeperPowerEvent event = new CreeperPowerEvent(this.getBukkitEntity(), entityweatherlighting.getBukkitEntity(), CreeperPowerEvent.PowerCause.LIGHTNING);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
2011-04-26 01:47:25 +02:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
2011-04-26 01:47:25 +02:00
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
this.setPowered(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPowered(boolean powered) {
|
|
|
|
if (!powered) {
|
|
|
|
this.datawatcher.watch(17, Byte.valueOf((byte) 0));
|
|
|
|
} else
|
|
|
|
// CraftBukkit end
|
|
|
|
this.datawatcher.watch(17, Byte.valueOf((byte) 1));
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2011-02-04 04:03:11 +01:00
|
|
|
}
|