-
Notifications
You must be signed in to change notification settings - Fork 497
/
TileEngineWithInventory.java
91 lines (71 loc) · 1.86 KB
/
TileEngineWithInventory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package buildcraft.energy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.inventory.SimpleInventory;
public abstract class TileEngineWithInventory extends TileEngine implements IInventory{
private final SimpleInventory inv;
public TileEngineWithInventory(int invSize) {
inv = new SimpleInventory(invSize, "Engine", 64);
}
/* IINVENTORY IMPLEMENTATION */
@Override
public int getSizeInventory() {
return inv.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slot) {
return inv.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
return inv.decrStackSize(slot, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return inv.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack) {
inv.setInventorySlotContents(slot, itemstack);
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInvName() {
return "Engine";
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this;
}
@Override
public void openChest() {
}
@Override
public void closeChest() {
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
inv.readFromNBT(data);
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
inv.writeToNBT(data);
}
@Override
public void delete() {
super.delete();
InvUtils.dropItems(worldObj, inv, xCoord, yCoord, zCoord);
}
}