Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3public class TileEntityChest extends TileEntity implements IInventory {
4
5 private ItemStack[] items = new ItemStack[27]; // CraftBukkit
6
7 // CraftBukkit start
8 public ItemStack[] getContents() {
9 return this.items;
10 }
11 // CraftBukkit end
12
13 public TileEntityChest() {
14 }
15
16 public int getSize() {
17 return 27;
18 }
19
20 public ItemStack getItem(int i) {
21 return this.items[i];
22 }
23
24 public ItemStack splitStack(int i, int j) {
25 if (this.items[i] != null) {
26 ItemStack itemstack;
27
28 if (this.items[i].count <= j) {
29 itemstack = this.items[i];
30 this.items[i] = null;
31 this.update();
32 return itemstack;
33 } else {
34 itemstack = this.items[i].a(j);
35 if (this.items[i].count == 0) {
36 this.items[i] = null;
37 }
38
39 this.update();
40 return itemstack;
41 }
42 } else {
43 return null;
44 }
45 }
46
47 public void setItem(int i, ItemStack itemstack) {
48 this.items[i] = itemstack;
49 if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
50 itemstack.count = this.getMaxStackSize();
51 }
52
53 this.update();
54 }
55
56 public String getName() {
57 return "Chest";
58 }
59
60 public void a(NBTTagCompound nbttagcompound) {
61 super.a(nbttagcompound);
62 NBTTagList nbttaglist = nbttagcompound.l("Items");
63
64 this.items = new ItemStack[this.getSize()];
65
66 for (int i = 0; i < nbttaglist.c(); ++i) {
67 NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
68 int j = nbttagcompound1.c("Slot") & 255;
69
70 if (j >= 0 && j < this.items.length) {
71 this.items[j] = new ItemStack(nbttagcompound1);
72 }
73 }
74 }
75
76 public void b(NBTTagCompound nbttagcompound) {
77 super.b(nbttagcompound);
78 NBTTagList nbttaglist = new NBTTagList();
79
80 for (int i = 0; i < this.items.length; ++i) {
81 if (this.items[i] != null) {
82 NBTTagCompound nbttagcompound1 = new NBTTagCompound();
83
84 nbttagcompound1.a("Slot", (byte) i);
85 this.items[i].a(nbttagcompound1);
86 nbttaglist.a((NBTBase) nbttagcompound1);
87 }
88 }
89
90 nbttagcompound.a("Items", (NBTBase) nbttaglist);
91 }
92
93 public int getMaxStackSize() {
94 return 64;
95 }
96
97 public boolean a_(EntityHuman entityhuman) {
98 return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D;
99 }
100}