Applied-Energistics-2-tiler.../items/storage/ItemBasicStorageCell.java

170 lines
4 KiB
Java
Raw Normal View History

package appeng.items.storage;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
2014-01-20 17:41:37 +01:00
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
2014-01-20 17:41:37 +01:00
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
2014-01-23 20:02:48 +01:00
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell;
2014-01-20 17:41:37 +01:00
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.features.AEFeature;
2014-01-20 17:41:37 +01:00
import appeng.core.localization.GuiText;
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;
2014-01-20 17:41:37 +01:00
import appeng.util.Platform;
2014-01-20 17:41:37 +01:00
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
{
final MaterialType component;
final int totalBytes;
final double idleDrain;
public ItemBasicStorageCell(MaterialType whichCell, int Kilobytes) {
super( ItemBasicStorageCell.class, Kilobytes + "k" );
setfeature( EnumSet.of( AEFeature.StorageCells ) );
2014-01-20 17:41:37 +01:00
setMaxStackSize( 1 );
totalBytes = Kilobytes * 1024;
component = whichCell;
switch (component)
{
case Cell1kPart:
2014-02-07 20:30:08 +01:00
idleDrain = 0.5;
break;
case Cell4kPart:
idleDrain = 1.0;
break;
case Cell16kPart:
idleDrain = 1.5;
break;
case Cell64kPart:
idleDrain = 2.0;
break;
default:
idleDrain = 0.0;
}
}
@Override
public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b)
{
2014-01-20 17:41:37 +01:00
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( i, StorageChannel.ITEMS );
2014-01-20 17:41:37 +01:00
if ( cdi instanceof CellInventoryHandler )
{
2014-01-20 17:41:37 +01:00
CellInventory cd = ((CellInventoryHandler) cdi).getCellInv();
if ( cd != null )
{
l.add( cd.usedBytes() + " " + GuiText.Of.getLocal() + " " + cd.totalBytes() + " " + GuiText.BytesUsed.getLocal() );
l.add( cd.storedItemTypes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalItemTypes() + " " + GuiText.Types.getLocal() );
/*
* if ( cd.isPreformatted() ) { String List = StatCollector.translateToLocal( cd.getListMode() ==
* ListMode.WHITELIST ? "AppEng.Gui.Whitelisted" : "AppEng.Gui.Blacklisted" ); if (
* cd.isFuzzyPreformatted() ) l.add( StatCollector.translateToLocal( "Appeng.GuiITooltip.Partitioned" )
* + " - " + List + " " + StatCollector.translateToLocal( "Appeng.GuiITooltip.Fuzzy" ) ); else l.add(
* StatCollector.translateToLocal( "Appeng.GuiITooltip.Partitioned" ) + " - " + List + " " +
* StatCollector.translateToLocal( "Appeng.GuiITooltip.Precise" ) ); }
2014-01-20 17:41:37 +01:00
*/
}
}
}
@Override
public int getBytes(ItemStack cellItem)
{
return totalBytes;
}
@Override
public int BytePerType(ItemStack iscellItem)
{
return 8;
}
@Override
public int getTotalTypes(ItemStack cellItem)
{
return 63;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requsetedAddition)
{
return false;
}
@Override
public boolean storableInStorageCell()
{
return false;
}
@Override
public boolean isStorageCell(ItemStack i)
{
return true;
}
@Override
public double getIdleDrain()
{
return idleDrain;
}
2014-01-20 17:41:37 +01:00
@Override
public IInventory getUpgradesInventory(ItemStack is)
{
return new CellUpgrades( is, 2 );
}
@Override
public IInventory getConfigInventory(ItemStack is)
{
return new CellConfig( is );
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is)
{
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
try
{
return FuzzyMode.valueOf( fz );
}
catch (Throwable t)
{
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
{
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
}
@Override
public String getUnlocalizedGroupName(ItemStack is)
{
return GuiText.StorageCells.getUnlocalized();
}
@Override
public boolean isEditable(ItemStack is)
{
return true;
}
}