API"ed the Storage Cell Classes.
This commit is contained in:
parent
a5379c82f8
commit
404cc08128
6 changed files with 44 additions and 15 deletions
|
@ -5,6 +5,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.IIcon;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
@ -58,7 +60,7 @@ public class BasicCellHandler implements ICellHandler
|
|||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
CellInventory inv = ((CellInventoryHandler) handler).getCellInv();
|
||||
ICellInventory inv = ((ICellInventoryHandler) handler).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import appeng.api.AEApi;
|
|||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
@ -23,7 +25,6 @@ import appeng.items.AEBaseItem;
|
|||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
@ -68,7 +69,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
|||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventory cd = ((CellInventoryHandler) cdi).getCellInv();
|
||||
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv();
|
||||
if ( cd != null )
|
||||
{
|
||||
l.add( cd.usedBytes() + " " + GuiText.Of.getLocal() + " " + cd.totalBytes() + " " + GuiText.BytesUsed.getLocal() );
|
||||
|
|
|
@ -24,6 +24,8 @@ import appeng.api.config.FuzzyMode;
|
|||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
@ -40,7 +42,6 @@ import appeng.hooks.DispenserMatterCannon;
|
|||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventory cd = ((CellInventoryHandler) cdi).getCellInv();
|
||||
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv();
|
||||
if ( cd != null )
|
||||
{
|
||||
lines.add( cd.usedBytes() + " " + GuiText.Of.getLocal() + " " + cd.totalBytes() + " " + GuiText.BytesUsed.getLocal() );
|
||||
|
|
|
@ -14,6 +14,8 @@ import appeng.api.implementations.guiobjects.IGuiItem;
|
|||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
@ -25,7 +27,6 @@ import appeng.items.contents.CellConfig;
|
|||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.contents.PortableCellViewer;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
|||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventory cd = ((CellInventoryHandler) cdi).getCellInv();
|
||||
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv();
|
||||
if ( cd != null )
|
||||
{
|
||||
lines.add( cd.usedBytes() + " " + GuiText.Of.getLocal() + " " + cd.totalBytes() + " " + GuiText.BytesUsed.getLocal() );
|
||||
|
|
|
@ -15,6 +15,7 @@ import appeng.api.config.FuzzyMode;
|
|||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
@ -23,7 +24,7 @@ import appeng.api.storage.data.IItemList;
|
|||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class CellInventory implements IMEInventory<IAEItemStack>
|
||||
public class CellInventory implements ICellInventory
|
||||
{
|
||||
|
||||
static final String ITEM_TYPE_TAG = "it";
|
||||
|
@ -192,11 +193,13 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
return cellItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int BytesPerType()
|
||||
{
|
||||
return CellType.BytePerType( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewItem()
|
||||
{
|
||||
long bytesFree = freeBytes();
|
||||
|
@ -254,32 +257,38 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long totalBytes()
|
||||
{
|
||||
return CellType.getBytes( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long freeBytes()
|
||||
{
|
||||
return totalBytes() - usedBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long usedBytes()
|
||||
{
|
||||
long bytesForItemCount = (storedItemCount() + unusedItemCount()) / 8;
|
||||
return storedItemTypes() * BytesPerType() + bytesForItemCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalItemTypes()
|
||||
{
|
||||
return MAX_ITEM_TYPES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long storedItemTypes()
|
||||
{
|
||||
return storedItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long storedItemCount()
|
||||
{
|
||||
return storedItemCount;
|
||||
|
@ -290,6 +299,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
tagCompound.setInteger( ITEM_COUNT_TAG, storedItemCount = (int) (storedItemCount + delta) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public long remainingItemTypes()
|
||||
{
|
||||
long basedOnStorage = freeBytes() / BytesPerType();
|
||||
|
@ -297,14 +307,14 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long remainingItemCount()
|
||||
{
|
||||
long remaining = freeBytes() * 8 + unusedItemCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
// returns the number of items that can be added without using an additional
|
||||
// byte!
|
||||
@Override
|
||||
public int unusedItemCount()
|
||||
{
|
||||
int div = (int) (storedItemCount() % 8);
|
||||
|
@ -479,26 +489,31 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return CellType.getIdleDrain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode()
|
||||
{
|
||||
return CellType.getFuzzyMode( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory()
|
||||
{
|
||||
return CellType.getConfigInventory( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory()
|
||||
{
|
||||
return CellType.getUpgradesInventory( this.i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell()
|
||||
{
|
||||
if ( canHoldNewItem() )
|
||||
|
@ -508,4 +523,10 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
|||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import appeng.api.config.FuzzyMode;
|
|||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
@ -16,28 +18,29 @@ import appeng.util.item.AEItemStack;
|
|||
import appeng.util.prioitylist.FuzzyPriorityList;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack>
|
||||
public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> implements ICellInventoryHandler
|
||||
{
|
||||
|
||||
NBTTagCompound openNbtData()
|
||||
{
|
||||
return Platform.openNbtData( getCellInv().i );
|
||||
return Platform.openNbtData( getCellInv().getItemStack() );
|
||||
}
|
||||
|
||||
public CellInventory getCellInv()
|
||||
@Override
|
||||
public ICellInventory getCellInv()
|
||||
{
|
||||
Object o = this.internal;
|
||||
|
||||
if ( o instanceof MEPassthru )
|
||||
o = ((MEPassthru) o).getInternal();
|
||||
|
||||
return (CellInventory) (o instanceof CellInventory ? o : null);
|
||||
return (ICellInventory) (o instanceof ICellInventory ? o : null);
|
||||
}
|
||||
|
||||
CellInventoryHandler(IMEInventory c) {
|
||||
super( c, IAEItemStack.class );
|
||||
|
||||
CellInventory ci = getCellInv();
|
||||
ICellInventory ci = getCellInv();
|
||||
if ( ci != null )
|
||||
{
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
|
Loading…
Reference in a new issue