2011-01-08 08:40:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-01-30 21:21:24 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.Server;
|
2011-01-08 08:40:42 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
2011-01-08 08:40:42 +01:00
|
|
|
import org.bukkit.event.entity.EntityCombustEvent;
|
2011-01-30 21:21:24 +01:00
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class EntitySkeleton extends EntityMonster {
|
2011-01-08 08:40:42 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
private static final ItemStack a = new ItemStack(Item.BOW, 1);
|
2011-01-10 09:30:34 +01:00
|
|
|
|
|
|
|
public EntitySkeleton(World world) {
|
|
|
|
super(world);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.texture = "/mob/skeleton.png";
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
protected String e() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeleton";
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
protected String f() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeletonhurt";
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
protected String g() {
|
2011-01-10 09:30:34 +01:00
|
|
|
return "mob.skeletonhurt";
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void r() {
|
|
|
|
if (this.world.d()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
float f = this.c(1.0F);
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-29 22:50:29 +01:00
|
|
|
CraftServer server = ((WorldServer) this.world).getServer();
|
2011-01-21 06:54:30 +01:00
|
|
|
org.bukkit.entity.Entity entity = this.getBukkitEntity();
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-03-26 22:32:56 +01:00
|
|
|
EntityCombustEvent event = new EntityCombustEvent(entity);
|
2011-01-10 09:30:34 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-01-10 09:30:34 +01:00
|
|
|
if (!event.isCancelled()) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.fireTicks = 300;
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
super.r();
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
protected void a(Entity entity, float f) {
|
|
|
|
if (f < 10.0F) {
|
|
|
|
double d0 = entity.locX - this.locX;
|
|
|
|
double d1 = entity.locZ - this.locZ;
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.attackTicks == 0) {
|
|
|
|
EntityArrow entityarrow = new EntityArrow(this.world, this);
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
++entityarrow.locY;
|
|
|
|
double d2 = entity.locY - 0.20000000298023224D - entityarrow.locY;
|
|
|
|
float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F;
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
|
|
|
|
this.world.addEntity(entityarrow);
|
2011-01-29 22:50:29 +01:00
|
|
|
entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F);
|
|
|
|
this.attackTicks = 30;
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
|
|
|
|
this.e = true;
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
protected int h() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return Item.ARROW.id;
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected void p() {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start - whole method
|
2011-01-30 21:21:24 +01:00
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-01-30 21:21:24 +01:00
|
|
|
int count = this.random.nextInt(3);
|
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count));
|
|
|
|
}
|
2011-01-14 14:31:10 +01:00
|
|
|
|
2011-01-30 21:21:24 +01:00
|
|
|
count = this.random.nextInt(3);
|
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count));
|
2011-01-14 14:31:10 +01:00
|
|
|
}
|
2011-01-10 09:30:34 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
CraftWorld cworld = ((WorldServer) world).getWorld();
|
|
|
|
Server server = ((WorldServer) world).getServer();
|
|
|
|
CraftEntity entity = (CraftEntity) getBukkitEntity();
|
|
|
|
|
2011-03-26 22:32:56 +01:00
|
|
|
EntityDeathEvent event = new EntityDeathEvent(entity, loot);
|
2011-01-30 21:21:24 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
for (org.bukkit.inventory.ItemStack stack: event.getDrops()) {
|
2011-01-30 21:21:24 +01:00
|
|
|
cworld.dropItemNaturally(entity.getLocation(), stack);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-10 09:30:34 +01:00
|
|
|
}
|
2011-01-08 08:40:42 +01:00
|
|
|
}
|