summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/TileEntity.java
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-02-25 23:56:31 -0500
committerEvilSeph <evilseph@gmail.com>2012-02-29 15:13:08 -0500
commit10e593649c224db2f0a4227bdf6eef44bfa16865 (patch)
treec8e04910be128eb9d98c475808c265a36adb4715 /src/main/java/net/minecraft/server/TileEntity.java
parentd20091e64c3582f792e90959266e855fe0829475 (diff)
downloadcraftbukkit-10e593649c224db2f0a4227bdf6eef44bfa16865.tar
craftbukkit-10e593649c224db2f0a4227bdf6eef44bfa16865.tar.gz
craftbukkit-10e593649c224db2f0a4227bdf6eef44bfa16865.tar.lz
craftbukkit-10e593649c224db2f0a4227bdf6eef44bfa16865.tar.xz
craftbukkit-10e593649c224db2f0a4227bdf6eef44bfa16865.zip
Imported from mc-dev:
- TileEntity - Container - ContainerFurnace - ContainerDispenser - ContainerChest - ContainerEnchantTableSubcontainer - ContainerEnchantTableInventory - ContainerBrewingStand
Diffstat (limited to 'src/main/java/net/minecraft/server/TileEntity.java')
-rw-r--r--src/main/java/net/minecraft/server/TileEntity.java123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
new file mode 100644
index 00000000..da9b4913
--- /dev/null
+++ b/src/main/java/net/minecraft/server/TileEntity.java
@@ -0,0 +1,123 @@
+package net.minecraft.server;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TileEntity {
+
+ private static Map a = new HashMap();
+ private static Map b = new HashMap();
+ public World world;
+ public int x;
+ public int y;
+ public int z;
+ protected boolean o;
+ public int p = -1;
+ public Block q;
+
+ public TileEntity() {}
+
+ private static void a(Class oclass, String s) {
+ if (b.containsKey(s)) {
+ throw new IllegalArgumentException("Duplicate id: " + s);
+ } else {
+ a.put(s, oclass);
+ b.put(oclass, s);
+ }
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ this.x = nbttagcompound.getInt("x");
+ this.y = nbttagcompound.getInt("y");
+ this.z = nbttagcompound.getInt("z");
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ String s = (String) b.get(this.getClass());
+
+ if (s == null) {
+ throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!");
+ } else {
+ nbttagcompound.setString("id", s);
+ nbttagcompound.setInt("x", this.x);
+ nbttagcompound.setInt("y", this.y);
+ nbttagcompound.setInt("z", this.z);
+ }
+ }
+
+ public void l_() {}
+
+ public static TileEntity c(NBTTagCompound nbttagcompound) {
+ TileEntity tileentity = null;
+
+ try {
+ Class oclass = (Class) a.get(nbttagcompound.getString("id"));
+
+ if (oclass != null) {
+ tileentity = (TileEntity) oclass.newInstance();
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
+ if (tileentity != null) {
+ tileentity.a(nbttagcompound);
+ } else {
+ System.out.println("Skipping TileEntity with id " + nbttagcompound.getString("id"));
+ }
+
+ return tileentity;
+ }
+
+ public int j() {
+ if (this.p == -1) {
+ this.p = this.world.getData(this.x, this.y, this.z);
+ }
+
+ return this.p;
+ }
+
+ public void update() {
+ if (this.world != null) {
+ this.p = this.world.getData(this.x, this.y, this.z);
+ this.world.b(this.x, this.y, this.z, this);
+ }
+ }
+
+ public Packet k() {
+ return null;
+ }
+
+ public boolean l() {
+ return this.o;
+ }
+
+ public void i() {
+ this.o = true;
+ }
+
+ public void m() {
+ this.o = false;
+ }
+
+ public void b(int i, int j) {}
+
+ public void d() {
+ this.q = null;
+ this.p = -1;
+ }
+
+ static {
+ a(TileEntityFurnace.class, "Furnace");
+ a(TileEntityChest.class, "Chest");
+ a(TileEntityRecordPlayer.class, "RecordPlayer");
+ a(TileEntityDispenser.class, "Trap");
+ a(TileEntitySign.class, "Sign");
+ a(TileEntityMobSpawner.class, "MobSpawner");
+ a(TileEntityNote.class, "Music");
+ a(TileEntityPiston.class, "Piston");
+ a(TileEntityBrewingStand.class, "Cauldron");
+ a(TileEntityEnchantTable.class, "EnchantTable");
+ a(TileEntityEnderPortal.class, "Airportal");
+ }
+}