Applied-Energistics-2-tiler.../items/tools/powered/ToolPortableCell.java

159 lines
3.9 KiB
Java
Raw Normal View History

2014-01-20 17:41:37 +01:00
package appeng.items.tools.powered;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
2014-02-09 02:34:52 +01:00
import net.minecraftforge.common.util.ForgeDirection;
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.guiobjects.IGuiItem;
2014-01-23 20:41:11 +01:00
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.items.IItemGroup;
2014-01-23 20:02:48 +01:00
import appeng.api.implementations.items.IStorageCell;
2014-03-28 01:48:38 +01:00
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
2014-01-20 17:41:37 +01:00
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
2014-02-09 06:08:27 +01:00
import appeng.core.AEConfig;
2014-01-20 17:41:37 +01:00
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.contents.PortableCellViewer;
2014-01-20 17:41:37 +01:00
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.util.Platform;
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup
2014-01-20 17:41:37 +01:00
{
public ToolPortableCell() {
super( ToolPortableCell.class, null );
setfeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) );
2014-02-09 06:08:27 +01:00
maxStoredPower = AEConfig.instance.portablecell_battery;
2014-01-20 17:41:37 +01:00
}
@Override
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer player)
{
Platform.openGUI( player, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_PORTABLE_CELL );
return item;
}
@Override
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
{
super.addInformation( is, player, lines, advancedItemTooltips );
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS );
if ( cdi instanceof CellInventoryHandler )
{
2014-03-28 01:48:38 +01:00
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv();
2014-01-20 17:41:37 +01:00
if ( cd != null )
{
2014-03-28 19:58:21 +01:00
lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalBytes() + " " + GuiText.BytesUsed.getLocal() );
lines.add( cd.getStoredItemTypes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalItemTypes() + " " + GuiText.Types.getLocal() );
2014-01-20 17:41:37 +01:00
}
}
}
@Override
public int getBytes(ItemStack cellItem)
{
return 512;
}
@Override
public int BytePerType(ItemStack iscellItem)
{
return 8;
}
@Override
public int getTotalTypes(ItemStack cellItem)
{
return 27;
}
@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 0.5;
}
@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 String getUnlocalizedGroupName(ItemStack is)
{
return GuiText.StorageCells.getUnlocalized();
}
2014-01-20 17:41:37 +01:00
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
{
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
}
@Override
public boolean isEditable(ItemStack is)
{
return true;
}
@Override
2014-01-23 20:41:11 +01:00
public IGuiItemObject getGuiObject(ItemStack is, World w, int x, int y, int z)
2014-01-20 17:41:37 +01:00
{
2014-01-23 20:02:48 +01:00
return new PortableCellViewer( is );
2014-01-20 17:41:37 +01:00
}
}