-
Notifications
You must be signed in to change notification settings - Fork 497
/
TransactorSided.java
39 lines (28 loc) · 1.16 KB
/
TransactorSided.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
package buildcraft.core.inventory;
import net.minecraftforge.common.ForgeDirection;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ISidedInventory;
/**
* Manages input on ISidedInventory
*/
public class TransactorSided extends TransactorSimple {
ISidedInventory sided;
public TransactorSided(ISidedInventory inventory) {
super(inventory);
this.sided = inventory;
}
@Override
protected int getPartialSlot(ItemStack stack, ForgeDirection orientation, int skipAhead) {
// If skipAhead is below the minimum required, we skip ahead to the first valid slot.
if(skipAhead < sided.getStartInventorySide(orientation))
skipAhead = sided.getStartInventorySide(orientation);
if(skipAhead > sided.getStartInventorySide(orientation) + sided.getSizeInventorySide(orientation))
return -1;
return getPartialSlot(stack, skipAhead, sided.getStartInventorySide(orientation) + sided.getSizeInventorySide(orientation));
}
@Override
protected int getEmptySlot(ForgeDirection orientation) {
return getEmptySlot(sided.getStartInventorySide(orientation),
sided.getStartInventorySide(orientation) + sided.getSizeInventorySide(orientation));
}
}