Paper/src/main/java/net/minecraft/server/EntityCreeper.java

117 lines
2.9 KiB
Java
Raw Normal View History

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.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
2011-03-18 22:57:22 +01:00
import org.bukkit.event.entity.ExplosionPrimeEvent;
2011-02-04 04:03:11 +01:00
// CraftBukkit end
public class EntityCreeper extends EntityMonster {
int fuseTicks;
2011-02-04 04:03:11 +01:00
int b;
public EntityCreeper(World world) {
super(world);
this.texture = "/mob/creeper.png";
}
protected void a() {
super.a();
this.datawatcher.a(16, Byte.valueOf((byte) -1));
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
}
2011-02-23 03:37:56 +01:00
public void f_() {
this.b = this.fuseTicks;
2011-02-04 04:03:11 +01:00
if (this.world.isStatic) {
2011-03-31 22:40:00 +02:00
int i = this.v();
2011-02-04 04:03:11 +01: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
}
this.fuseTicks += i;
if (this.fuseTicks < 0) {
this.fuseTicks = 0;
2011-02-04 04:03:11 +01:00
}
if (this.fuseTicks >= 30) {
this.fuseTicks = 30;
2011-02-04 04:03:11 +01:00
}
}
2011-02-23 03:37:56 +01:00
super.f_();
2011-02-04 04:03:11 +01:00
}
protected String f() {
return "mob.creeper";
}
protected String g() {
return "mob.creeperdeath";
}
2011-02-23 03:37:56 +01:00
public void a(Entity entity) {
super.a(entity);
2011-02-04 04:03:11 +01:00
if (entity instanceof EntitySkeleton) {
2011-02-23 03:37:56 +01:00
this.b(Item.GOLD_RECORD.id + this.random.nextInt(2), 1);
2011-02-04 04:03:11 +01:00
}
}
protected void a(Entity entity, float f) {
2011-03-31 22:40:00 +02:00
int i = this.v();
2011-02-04 04:03:11 +01:00
if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) {
2011-02-23 03:37:56 +01:00
this.e(-1);
--this.fuseTicks;
if (this.fuseTicks < 0) {
this.fuseTicks = 0;
2011-02-04 04:03:11 +01:00
}
} else {
if (this.fuseTicks == 0) {
this.world.makeSound(this, "random.fuse", 1.0F, 0.5F);
2011-02-04 04:03:11 +01:00
}
2011-02-23 03:37:56 +01:00
this.e(1);
++this.fuseTicks;
if (this.fuseTicks >= 30) {
2011-02-23 13:56:36 +01:00
// CraftBukkit start
2011-02-04 04:03:11 +01:00
CraftServer server = ((WorldServer) this.world).getServer();
2011-02-23 13:56:36 +01:00
ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 3.0F, false);
2011-02-04 04:03:11 +01:00
server.getPluginManager().callEvent(event);
2011-02-23 13:56:36 +01:00
if (!event.isCancelled()) {
this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
this.die();
2011-02-04 04:03:11 +01:00
} else {
this.fuseTicks = 0;
2011-02-04 04:03:11 +01:00
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-02-04 04:03:11 +01:00
}
this.e = true;
}
}
protected int h() {
return Item.SULPHUR.id;
}
2011-03-31 22:40:00 +02:00
private int v() {
2011-02-04 04:03:11 +01:00
return this.datawatcher.a(16);
}
2011-02-23 03:37:56 +01:00
private void e(int i) {
2011-02-04 04:03:11 +01:00
this.datawatcher.b(16, Byte.valueOf((byte) i));
}
}