-
Notifications
You must be signed in to change notification settings - Fork 497
/
TileChargingTable.java
49 lines (40 loc) · 1.35 KB
/
TileChargingTable.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
package buildcraft.silicon;
import buildcraft.api.tiles.IHasWork;
import buildcraft.core.utils.StringUtils;
import cofh.api.energy.IEnergyContainerItem;
import net.minecraft.item.ItemStack;
public class TileChargingTable extends TileLaserTableBase implements IHasWork {
@Override
public int getRequiredEnergy() {
ItemStack stack = this.getStackInSlot(0);
if (stack != null && stack.getItem() != null && stack.getItem() instanceof IEnergyContainerItem) {
IEnergyContainerItem containerItem = (IEnergyContainerItem) stack.getItem();
return containerItem.getMaxEnergyStored(stack) - containerItem.getEnergyStored(stack);
}
return 0;
}
@Override
public boolean hasWork() {
return getRequiredEnergy() > 0;
}
@Override
public boolean canCraft() {
return hasWork();
}
@Override
public int getSizeInventory() {
return 1;
}
@Override
public String getInventoryName() {
return StringUtils.localize("tile.chargingTableBlock.name");
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return slot == 0 && stack != null && stack.getItem() != null && stack.getItem() instanceof IEnergyContainerItem;
}
}