From 2de3e2e7e406baaaddd5c71fa283d81dacabf815 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Mon, 17 Jan 2011 07:03:15 +0800 Subject: [PATCH] created getBukkitEntity() in minecraft.server.Entity This returns a protected field that is set in the constructor of each minecraft.server.Entity to a new CraftEntity of some specific type. --- src/main/java/net/minecraft/server/Entity.java | 10 ++++++++++ src/main/java/net/minecraft/server/EntityArrow.java | 9 ++++++--- src/main/java/net/minecraft/server/EntityBoat.java | 5 +++++ src/main/java/net/minecraft/server/EntityEgg.java | 5 +++++ src/main/java/net/minecraft/server/EntityFireball.java | 5 +++++ src/main/java/net/minecraft/server/EntityFish.java | 5 +++++ src/main/java/net/minecraft/server/EntityMinecart.java | 7 ++++++- src/main/java/net/minecraft/server/EntityMobs.java | 5 +++++ src/main/java/net/minecraft/server/EntityPlayer.java | 4 ++++ src/main/java/net/minecraft/server/EntityPlayerMP.java | 9 +++++++++ src/main/java/net/minecraft/server/EntitySkeleton.java | 4 ++++ src/main/java/net/minecraft/server/EntitySnowball.java | 4 ++++ src/main/java/net/minecraft/server/EntityZombie.java | 4 ++++ 13 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 7f8aa4341e..f39c29e737 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -77,6 +77,8 @@ public abstract class Entity { public int ah; public int ai; public int aj; + + protected org.bukkit.entity.Entity bukkitEntity; //CraftBukkit public Entity(World world) { g = a++; @@ -116,6 +118,8 @@ public abstract class Entity { a(0.0D, 0.0D, 0.0D); af.a(0, ((Byte.valueOf((byte) 0)))); a(); + + bukkitEntity = null; //CraftBukkit } protected abstract void a(); @@ -952,4 +956,10 @@ public abstract class Entity { af.b(0, ((Byte.valueOf((byte) (byte0 & ~(1 << i1)))))); } } + + //CraftBukkit start + public org.bukkit.entity.Entity getBukkitEntity(){ + return this.bukkitEntity; + } + //CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index e02cc6beec..38260d00a9 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -7,9 +7,7 @@ import java.util.Random; import org.bukkit.craftbukkit.entity.CraftArrow; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; //CraftBukkit end @@ -25,7 +23,7 @@ public class EntityArrow extends Entity { public EntityLiving b; private int al; private int am; - + public EntityArrow(World world) { super(world); c = -1; @@ -36,6 +34,11 @@ public class EntityArrow extends Entity { a = 0; am = 0; a(0.5F, 0.5F); + + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftArrow(server, this); + //CraftBukkit end } public EntityArrow(World world, double d1, double d2, double d3) { diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index 3c01822d21..24ae460643 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -5,6 +5,7 @@ import java.util.Random; // CraftBukkit start import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftArrow; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.CraftMappable; @@ -48,6 +49,10 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit M = false; handleCreation(world); // CraftBukkit + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftBoat(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index ed244d269c..75ebe9bbe5 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -5,6 +5,7 @@ import java.util.Random; // CraftBukkit start import org.bukkit.entity.MobType; +import org.bukkit.craftbukkit.entity.CraftArrow; import org.bukkit.craftbukkit.entity.CraftEgg; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -38,6 +39,10 @@ public class EntityEgg extends Entity { a = 0; am = 0; a(0.25F, 0.25F); + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftEgg(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 6623f1e13b..d2b9007ced 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Random; //CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftEgg; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftFireball; import org.bukkit.craftbukkit.entity.CraftLivingEntity; @@ -37,6 +38,10 @@ public class EntityFireball extends Entity { a = 0; ap = 0; a(1.0F, 1.0F); + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftFireball(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java index ed56692869..c0aabe6d22 100644 --- a/src/main/java/net/minecraft/server/EntityFish.java +++ b/src/main/java/net/minecraft/server/EntityFish.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Random; // CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftEgg; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftFireball; import org.bukkit.craftbukkit.entity.CraftFish; @@ -45,6 +46,10 @@ public class EntityFish extends Entity { ao = 0; c = null; a(0.25F, 0.25F); + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftFish(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 98b08dea5c..59cf2d518d 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -5,6 +5,7 @@ import java.util.Random; // CraftBukkit start import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftEgg; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.CraftMappable; import org.bukkit.craftbukkit.entity.CraftMinecart; @@ -104,7 +105,6 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable private double flyingX = 0.94999998807907104; private double flyingY = 0.94999998807907104; private double flyingZ = 0.94999998807907104; - public CraftEntity getCraftEntity() { return minecart; } @@ -127,6 +127,11 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable M = false; handleCreation(world); // CraftBukkit + //CraftBukkit start + //TODO need to handle powered and storage minecarts + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftMinecart(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityMobs.java b/src/main/java/net/minecraft/server/EntityMobs.java index 633339a0fb..ee3e84f424 100644 --- a/src/main/java/net/minecraft/server/EntityMobs.java +++ b/src/main/java/net/minecraft/server/EntityMobs.java @@ -5,6 +5,7 @@ import java.util.Random; //CraftBukkit start import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.entity.CraftMinecart; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -19,6 +20,10 @@ public class EntityMobs extends EntityCreature implements IMobs { super(world); c = 2; aZ = 20; + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftLivingEntity(server, this); + //CraftBukkit end } public void o() { diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index f971219d30..3314d43125 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -51,6 +51,10 @@ public abstract class EntityPlayer extends EntityLiving { aR = 180F; Y = 20; aP = "/mob/char.png"; + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftLivingEntity(server, this); + //CraftBukkit end } public void b_() { diff --git a/src/main/java/net/minecraft/server/EntityPlayerMP.java b/src/main/java/net/minecraft/server/EntityPlayerMP.java index adb2f6fecb..5f1b184bd8 100644 --- a/src/main/java/net/minecraft/server/EntityPlayerMP.java +++ b/src/main/java/net/minecraft/server/EntityPlayerMP.java @@ -2,6 +2,11 @@ package net.minecraft.server; import java.util.*; +//CraftBukkit start +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftPlayer; +//CraftBukkit end + public class EntityPlayerMP extends EntityPlayer implements ICrafting { public NetServerHandler a; @@ -43,6 +48,10 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting { aw = s; c = iteminworldmanager; H = 0.0F; + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftPlayer(server, this); + //CraftBukkit end } public void l() { diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index 1ff4c47911..9c548db478 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -16,6 +16,10 @@ public class EntitySkeleton extends EntityMobs { public EntitySkeleton(World world) { super(world); aP = "/mob/skeleton.png"; + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftLivingEntity(server, this); + //CraftBukkit end } protected String e() { diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index 4e479d5308..700cac8bd6 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -34,6 +34,10 @@ public class EntitySnowball extends Entity { a = 0; am = 0; a(0.25F, 0.25F); + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftSnowball(server, this); + //CraftBukkit end } protected void a() {} diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 96dd4270b3..870700bf2d 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -16,6 +16,10 @@ public class EntityZombie extends EntityMobs { aP = "/mob/zombie.png"; bC = 0.5F; c = 5; + //CraftBukkit start + CraftServer server = ((WorldServer) this.l).getServer(); + this.bukkitEntity = new CraftLivingEntity(server, this); + //CraftBukkit end } public void o() {