Merge pull request #432 from thatsIch/portcell

Potentially fixes #287 by removing the second call hook to open the GUI of the portable cell
This commit is contained in:
thatsIch
2014-11-16 16:25:32 +01:00
@@ -18,6 +18,7 @@
package appeng.items.tools.powered; package appeng.items.tools.powered;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -27,6 +28,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItem;
@@ -49,32 +51,25 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler; import appeng.me.storage.CellInventoryHandler;
import appeng.util.Platform; import appeng.util.Platform;
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup
{ {
public ToolPortableCell()
public ToolPortableCell() { {
super( ToolPortableCell.class, null ); super( ToolPortableCell.class, null );
setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) ); setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) );
maxStoredPower = AEConfig.instance.portableCellBattery; maxStoredPower = AEConfig.instance.portableCellBattery;
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer player) public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer player )
{ {
Platform.openGUI( player, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_PORTABLE_CELL ); Platform.openGUI( player, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_PORTABLE_CELL );
return item; return item;
} }
@Override @Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World w, int x, int y, int z, int side, public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
float hitX, float hitY, float hitZ)
{
onItemRightClick( item, w, player );
return true;
}
@Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
{ {
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation ); super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
@@ -82,7 +77,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
if ( cdi instanceof CellInventoryHandler ) if ( cdi instanceof CellInventoryHandler )
{ {
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv(); ICellInventory cd = ( ( ICellInventoryHandler ) cdi ).getCellInv();
if ( cd != null ) if ( cd != null )
{ {
lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalBytes() + " " + GuiText.BytesUsed.getLocal() ); lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalBytes() + " " + GuiText.BytesUsed.getLocal() );
@@ -92,25 +87,25 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
} }
@Override @Override
public int getBytes(ItemStack cellItem) public int getBytes( ItemStack cellItem )
{ {
return 512; return 512;
} }
@Override @Override
public int BytePerType(ItemStack cell) public int BytePerType( ItemStack cell )
{ {
return 8; return 8;
} }
@Override @Override
public int getTotalTypes(ItemStack cellItem) public int getTotalTypes( ItemStack cellItem )
{ {
return 27; return 27;
} }
@Override @Override
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) public boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition )
{ {
return false; return false;
} }
@@ -122,7 +117,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
} }
@Override @Override
public boolean isStorageCell(ItemStack i) public boolean isStorageCell( ItemStack i )
{ {
return true; return true;
} }
@@ -134,51 +129,51 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
} }
@Override @Override
public IInventory getUpgradesInventory(ItemStack is) public IInventory getUpgradesInventory( ItemStack is )
{ {
return new CellUpgrades( is, 2 ); return new CellUpgrades( is, 2 );
} }
@Override @Override
public IInventory getConfigInventory(ItemStack is) public IInventory getConfigInventory( ItemStack is )
{ {
return new CellConfig( is ); return new CellConfig( is );
} }
@Override @Override
public FuzzyMode getFuzzyMode(ItemStack is) public FuzzyMode getFuzzyMode( ItemStack is )
{ {
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" ); String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
try try
{ {
return FuzzyMode.valueOf( fz ); return FuzzyMode.valueOf( fz );
} }
catch (Throwable t) catch ( Throwable t )
{ {
return FuzzyMode.IGNORE_ALL; return FuzzyMode.IGNORE_ALL;
} }
} }
@Override @Override
public String getUnlocalizedGroupName(Set<ItemStack> others, ItemStack is) public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
{ {
return GuiText.StorageCells.getUnlocalized(); return GuiText.StorageCells.getUnlocalized();
} }
@Override @Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
{ {
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
} }
@Override @Override
public boolean isEditable(ItemStack is) public boolean isEditable( ItemStack is )
{ {
return true; return true;
} }
@Override @Override
public IGuiItemObject getGuiObject(ItemStack is, World w, int x, int y, int z) public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
{ {
return new PortableCellViewer( is ); return new PortableCellViewer( is );
} }