-
Notifications
You must be signed in to change notification settings - Fork 497
/
SidedInventoryAdapter.java
91 lines (74 loc) · 2.1 KB
/
SidedInventoryAdapter.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.core.utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
/**
* This class is responsible for abstracting an ISidedInventory as a normal IInventory
*
* @author Krapht
*
*/
public class SidedInventoryAdapter implements IInventory {
private final ISidedInventory _sidedInventory;
private final ForgeDirection _side;
private final int _slotOffset;
public SidedInventoryAdapter(ISidedInventory sidedInventory, ForgeDirection side) {
_sidedInventory = sidedInventory;
_side = side;
_slotOffset = _sidedInventory.getStartInventorySide(side);
}
@Override
public int getSizeInventory() {
return _sidedInventory.getSizeInventorySide(_side);
}
@Override
public ItemStack getStackInSlot(int i) {
return _sidedInventory.getStackInSlot(i + _slotOffset);
}
@Override
public ItemStack decrStackSize(int i, int j) {
return _sidedInventory.decrStackSize(i + _slotOffset, j);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
_sidedInventory.setInventorySlotContents(i + _slotOffset, itemstack);
}
@Override
public String getInvName() {
return _sidedInventory.getInvName();
}
@Override
public int getInventoryStackLimit() {
return _sidedInventory.getInventoryStackLimit();
}
@Override
public void onInventoryChanged() {
_sidedInventory.onInventoryChanged();
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return _sidedInventory.isUseableByPlayer(entityplayer);
}
@Override
public void openChest() {
_sidedInventory.openChest();
}
@Override
public void closeChest() {
_sidedInventory.closeChest();
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return _sidedInventory.getStackInSlotOnClosing(slot + _slotOffset);
}
@Override
public boolean isInvNameLocalized() {
return false;
}
@Override
public boolean isStackValidForSlot(int i, ItemStack itemstack) {
return true;
}
}