Can now charge ic2 items, closes #1202
This commit is contained in:
parent
850ec54bd3
commit
e2f177b757
3 changed files with 17 additions and 9 deletions
|
@ -44,6 +44,8 @@ import reborncore.common.powerSystem.TilePowerAcceptor;
|
|||
import techreborn.Core;
|
||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||
import techreborn.client.container.builder.slot.UpgradeSlot;
|
||||
import techreborn.compat.CompatManager;
|
||||
import techreborn.utils.IC2ItemCharger;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntConsumer;
|
||||
|
@ -89,7 +91,7 @@ public class ContainerTileInventoryBuilder {
|
|||
public ContainerTileInventoryBuilder energySlot(final int index, final int x, final int y) {
|
||||
this.parent.slots.add(new FilteredSlot(this.tile, index, x, y)
|
||||
.setFilter(stack -> stack.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)
|
||||
|| stack.getItem() instanceof IEnergyInterfaceItem));
|
||||
|| stack.getItem() instanceof IEnergyInterfaceItem || (CompatManager.isIC2Loaded && IC2ItemCharger.isIC2PoweredItem(stack))));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,13 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
|
|||
super.update();
|
||||
if (!inventory.getStackInSlot(0).isEmpty()) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
|
||||
return;
|
||||
}
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
||||
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
|
||||
if (canUseEnergy(item.getMaxTransfer(stack))) {
|
||||
useEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
||||
if (stack.getItem() instanceof IEnergyItemInfo) {
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
||||
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) {
|
||||
if (canUseEnergy(item.getMaxTransfer(stack))) {
|
||||
useEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CompatManager.isIC2Loaded){
|
||||
|
|
|
@ -40,4 +40,11 @@ public class IC2ItemCharger {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isIC2PoweredItem(ItemStack stack){
|
||||
if(stack.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
return stack.getItem() instanceof IElectricItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue