Add ic2 item discharge support, closes #1357

This commit is contained in:
modmuss50 2017-12-17 21:36:48 +00:00
parent 82eb0f62d6
commit 7f289e2356
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
2 changed files with 19 additions and 8 deletions

View file

@ -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);
}
}
}

View file

@ -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;