From 103d4ee88728b80887e007b07254ceba77e5a943 Mon Sep 17 00:00:00 2001 From: Taylor Kelly Date: Sat, 8 Jan 2011 15:40:42 +0800 Subject: [PATCH] EntityCombustEvent --- .../net/minecraft/server/EntitySkeleton.java | 87 +++++++++++++++++++ .../net/minecraft/server/EntityZombie.java | 54 ++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/main/java/net/minecraft/server/EntitySkeleton.java create mode 100644 src/main/java/net/minecraft/server/EntityZombie.java diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java new file mode 100644 index 0000000000..2cd50c1ac1 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -0,0 +1,87 @@ +package net.minecraft.server; + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftEntity; +import org.bukkit.craftbukkit.CraftLivingEntity; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.entity.EntityCombustEvent; + +public class EntitySkeleton extends EntityMobs { + + private static final ItemStack a; + + public EntitySkeleton(World world) { + super(world); + aQ = "/mob/skeleton.png"; + } + + protected String d() { + return "mob.skeleton"; + } + + protected String e() { + return "mob.skeletonhurt"; + } + + protected String f() { + return "mob.skeletonhurt"; + } + + public void G() { + if (l.b()) { + float f1 = b(1.0F); + + if (f1 > 0.5F && l.h(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) { + //Craftbukkit start + CraftServer server = ((WorldServer) l).getServer(); + EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, new CraftLivingEntity(server, (EntityLiving) this)); + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + Z = 300; + } + //Craftbukkit stop + } + } + super.G(); + } + + protected void a(Entity entity, float f1) { + if (f1 < 10F) { + double d1 = entity.p - p; + double d2 = entity.r - r; + + if (bg == 0) { + EntityArrow entityarrow = new EntityArrow(l, this); + + entityarrow.q += 1.3999999761581421D; + double d3 = entity.q - 0.20000000298023224D - entityarrow.q; + float f2 = MathHelper.a(d1 * d1 + d2 * d2) * 0.2F; + + l.a(this, "random.bow", 1.0F, 1.0F / (W.nextFloat() * 0.4F + 0.8F)); + l.a(entityarrow); + entityarrow.a(d1, d3 + (double) f2, d2, 0.6F, 12F); + bg = 30; + } + v = (float) ((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F; + ak = true; + } + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + } + + protected int g() { + return Item.j.aW; + } + + static { + a = new ItemStack(Item.i, 1); + } +} diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java new file mode 100644 index 0000000000..c869aa81a3 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -0,0 +1,54 @@ +package net.minecraft.server; + + +import java.util.Random; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.event.Event.Type; +import org.bukkit.event.entity.EntityCombustEvent; + + +public class EntityZombie extends EntityMobs { + + public EntityZombie(World world) { + super(world); + aQ = "/mob/zombie.png"; + bD = 0.5F; + f = 5; + } + + public void G() { + if (l.b()) { + float f1 = b(1.0F); + + if (f1 > 0.5F && l.h(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) { + //Craftbukkit start + CraftServer server = ((WorldServer) l).getServer(); + EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, new CraftLivingEntity(server, (EntityLiving) this)); + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + Z = 300; + } + //Craftbukkit stop + } + } + super.G(); + } + + protected String d() { + return "mob.zombie"; + } + + protected String e() { + return "mob.zombiehurt"; + } + + protected String f() { + return "mob.zombiedeath"; + } + + protected int g() { + return Item.J.aW; + } +} +