Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 108 lines 2.7 kB view raw
1package net.minecraft.server; 2 3import java.util.HashMap; 4import java.util.Map; 5 6public class TileEntity { 7 8 private static Map a = new HashMap(); 9 private static Map b = new HashMap(); 10 public World world; 11 public int x; 12 public int y; 13 public int z; 14 protected boolean h; 15 16 public TileEntity() { 17 } 18 19 private static void a(Class oclass, String s) { 20 if (b.containsKey(s)) { 21 throw new IllegalArgumentException("Duplicate id: " + s); 22 } else { 23 a.put(s, oclass); 24 b.put(oclass, s); 25 } 26 } 27 28 public void a(NBTTagCompound nbttagcompound) { 29 this.x = nbttagcompound.e("x"); 30 this.y = nbttagcompound.e("y"); 31 this.z = nbttagcompound.e("z"); 32 } 33 34 public void b(NBTTagCompound nbttagcompound) { 35 String s = (String) b.get(this.getClass()); 36 37 if (s == null) { 38 throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!"); 39 } else { 40 nbttagcompound.setString("id", s); 41 nbttagcompound.a("x", this.x); 42 nbttagcompound.a("y", this.y); 43 nbttagcompound.a("z", this.z); 44 } 45 } 46 47 public void g_() { 48 } 49 50 public static TileEntity c(NBTTagCompound nbttagcompound) { 51 TileEntity tileentity = null; 52 53 try { 54 Class oclass = (Class) a.get(nbttagcompound.getString("id")); 55 56 if (oclass != null) { 57 tileentity = (TileEntity) oclass.newInstance(); 58 } 59 } catch (Exception exception) { 60 exception.printStackTrace(); 61 } 62 63 if (tileentity != null) { 64 tileentity.a(nbttagcompound); 65 } else { 66 System.out.println("Skipping TileEntity with id " + nbttagcompound.getString("id")); 67 } 68 69 return tileentity; 70 } 71 72 public int e() { 73 return this.world.getData(this.x, this.y, this.z); 74 } 75 76 public void update() { 77 if (this.world != null) { 78 this.world.b(this.x, this.y, this.z, this); 79 } 80 } 81 82 public Packet f() { 83 return null; 84 } 85 86 public boolean g() { 87 return this.h; 88 } 89 90 public void h() { 91 this.h = true; 92 } 93 94 public void j() { 95 this.h = false; 96 } 97 98 static { 99 a(TileEntityFurnace.class, "Furnace"); 100 a(TileEntityChest.class, "Chest"); 101 a(TileEntityRecordPlayer.class, "RecordPlayer"); 102 a(TileEntityDispenser.class, "Trap"); 103 a(TileEntitySign.class, "Sign"); 104 a(TileEntityMobSpawner.class, "MobSpawner"); 105 a(TileEntityNote.class, "Music"); 106 a(TileEntityPiston.class, "Piston"); 107 } 108}