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; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; import appeng.api.config.FuzzyMode; 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.IMEInventory; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.core.AEConfig; 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; import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.me.storage.CellInventory; import appeng.me.storage.CellInventoryHandler; import appeng.util.Platform; public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup { public ToolPortableCell() { super( ToolPortableCell.class, null ); setfeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) ); maxStoredPower = AEConfig.instance.portablecell_battery; } @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 cdi = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); if ( cdi instanceof CellInventoryHandler ) { CellInventory cd = ((CellInventoryHandler) cdi).getCellInv(); if ( cd != null ) { lines.add( cd.usedBytes() + " " + GuiText.Of.getLocal() + " " + cd.totalBytes() + " " + GuiText.BytesUsed.getLocal() ); lines.add( cd.storedItemTypes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalItemTypes() + " " + GuiText.Types.getLocal() ); } } } @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(); } @Override public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) { Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); } @Override public boolean isEditable(ItemStack is) { return true; } @Override public IGuiItemObject getGuiObject(ItemStack is, World w, int x, int y, int z) { return new PortableCellViewer( is ); } }