Drives/Chests now charge power based on Cell Types.

This commit is contained in:
AlgorithmX2 2014-01-24 10:32:31 -06:00
parent 35d51e23fb
commit 1d539a33a8
3 changed files with 25 additions and 3 deletions

View file

@ -58,7 +58,7 @@ public class BasicCellHandler implements ICellHandler
@Override
public double cellIdleDrain(ItemStack is, IMEInventory handler)
{
CellInventory inv = (CellInventory) handler;
CellInventory inv = ((CellInventoryHandler) handler).getCellInv();
return inv.getIdleDrain();
}
}

View file

@ -41,6 +41,7 @@ import appeng.api.storage.IMEMonitorHandlerReciever;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.helpers.AENoHandler;
@ -321,8 +322,21 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
isCached = true;
cellHandler = AEApi.instance().registries().cell().getHander( is );
icell = wrap( cellHandler.getCellInventory( is, StorageChannel.ITEMS ) );
fcell = wrap( cellHandler.getCellInventory( is, StorageChannel.FLUIDS ) );
double power = 1.0;
IMEInventoryHandler<IAEItemStack> itemCell = cellHandler.getCellInventory( is, StorageChannel.ITEMS );
IMEInventoryHandler<IAEFluidStack> fluidCell = cellHandler.getCellInventory( is, StorageChannel.FLUIDS );
if ( itemCell != null )
power += cellHandler.cellIdleDrain( is, itemCell );
else if ( fluidCell != null )
power += cellHandler.cellIdleDrain( is, fluidCell );
gridProxy.setIdlePowerUsage( power );
icell = wrap( itemCell );
fcell = wrap( fluidCell );
}
}

View file

@ -188,6 +188,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
items = new LinkedList();
fluids = new LinkedList();
double power = 2.0;
for (int x = 0; x < inv.getSizeInventory(); x++)
{
ItemStack is = inv.getStackInSlot( x );
@ -204,6 +206,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
if ( cell != null )
{
power += handlersBySlot[x].cellIdleDrain( is, cell );
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, handlersBySlot[x], this );
ih.myPriority = priority;
invBySlot[x] = ih;
@ -215,6 +219,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
if ( cell != null )
{
power += handlersBySlot[x].cellIdleDrain( is, cell );
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, handlersBySlot[x], this );
ih.myPriority = priority;
invBySlot[x] = ih;
@ -225,6 +231,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
}
}
gridProxy.setIdlePowerUsage( power );
isCached = true;
}
}