From 0066ce461d931617bf31719a386310c9363e7ba9 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Fri, 14 Nov 2014 11:28:33 +0100 Subject: [PATCH] Potentially fixes #287 by removing the second call hook to open the GUI of the portable cell Added copyrights Reformated code Rearranged code --- .../items/tools/powered/ToolPortableCell.java | 65 +++++++++++-------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java index c07b3a88807..12b7302b35f 100644 --- a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java +++ b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java @@ -1,5 +1,24 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + package appeng.items.tools.powered; + import java.util.EnumSet; import java.util.List; import java.util.Set; @@ -9,6 +28,7 @@ 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; @@ -31,32 +51,25 @@ import appeng.me.storage.CellInventoryHandler; import appeng.util.Platform; + public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup { - - public ToolPortableCell() { + public ToolPortableCell() + { super( ToolPortableCell.class, null ); setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) ); maxStoredPower = AEConfig.instance.portableCellBattery; } @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 ); return item; } - - @Override - public boolean onItemUse(ItemStack item, EntityPlayer player, World w, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) - { - onItemRightClick( item, w, player ); - return true; - } @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) { super.addCheckedInformation( stack, player, lines, displayAdditionalInformation ); @@ -64,7 +77,7 @@ public void addCheckedInformation(ItemStack stack, EntityPlayer player, List others, ItemStack is) + public String getUnlocalizedGroupName( Set others, ItemStack is ) { return GuiText.StorageCells.getUnlocalized(); } @Override - public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) + public void setFuzzyMode( ItemStack is, FuzzyMode fzMode ) { Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); } @Override - public boolean isEditable(ItemStack is) + public boolean isEditable( ItemStack is ) { return true; } @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 ); }