Add ic2 item discharge support, closes #1357
This commit is contained in:
parent
82eb0f62d6
commit
7f289e2356
2 changed files with 19 additions and 8 deletions
|
@ -84,16 +84,18 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
|
|||
}
|
||||
if (!inventory.getStackInSlot(1).isEmpty()) {
|
||||
ItemStack stack = inventory.getStackInSlot(1);
|
||||
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
|
||||
return;
|
||||
}
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||
if (item.canProvideEnergy(stack)) {
|
||||
if (getEnergy() != getMaxPower() && PoweredItem.getEnergy(stack) > 0) {
|
||||
addEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||
if (stack.getItem() instanceof IEnergyItemInfo) {
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||
if (item.canProvideEnergy(stack)) {
|
||||
if (getEnergy() != getMaxPower() && PoweredItem.getEnergy(stack) > 0) {
|
||||
addEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CompatManager.isIC2Loaded){
|
||||
IC2ItemCharger.dischargeIc2Item(this, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,15 @@ public class IC2ItemCharger {
|
|||
}
|
||||
}
|
||||
|
||||
public static void dischargeIc2Item(TilePowerAcceptor tilePowerAcceptor, ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return;
|
||||
}
|
||||
if(stack.getItem() instanceof IElectricItem){
|
||||
tilePowerAcceptor.addEnergy(ElectricItem.manager.discharge(stack, tilePowerAcceptor.getFreeSpace(), 4, false, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isIC2PoweredItem(ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue