Use correct return type as variable

Added copyright
Reformat code
Rearrange code
This commit is contained in:
thatsIch
2014-11-13 13:35:51 +01:00
parent d6506a1778
commit 2194bd708c
@@ -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 <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.storage; package appeng.items.storage;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -10,6 +29,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.config.IncludeExclude; import appeng.api.config.IncludeExclude;
@@ -17,7 +37,7 @@ import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.ICellInventory; import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel; import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
@@ -31,15 +51,16 @@ import appeng.items.materials.MaterialType;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
{ {
final MaterialType component; final MaterialType component;
final int totalBytes; final int totalBytes;
final int perType; final int perType;
final double idleDrain; final double idleDrain;
public ItemBasicStorageCell(MaterialType whichCell, int Kilobytes) { public ItemBasicStorageCell( MaterialType whichCell, int Kilobytes )
{
super( ItemBasicStorageCell.class, Kilobytes + "k" ); super( ItemBasicStorageCell.class, Kilobytes + "k" );
this.setFeature( EnumSet.of( AEFeature.StorageCells ) ); this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
@@ -47,84 +68,85 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
this.totalBytes = Kilobytes * 1024; this.totalBytes = Kilobytes * 1024;
this.component = whichCell; this.component = whichCell;
switch (this.component) switch ( this.component )
{ {
case Cell1kPart: case Cell1kPart:
this.idleDrain = 0.5; this.idleDrain = 0.5;
this.perType = 8; this.perType = 8;
break; break;
case Cell4kPart: case Cell4kPart:
this.idleDrain = 1.0; this.idleDrain = 1.0;
this.perType = 32; this.perType = 32;
break; break;
case Cell16kPart: case Cell16kPart:
this.idleDrain = 1.5; this.idleDrain = 1.5;
this.perType = 128; this.perType = 128;
break; break;
case Cell64kPart: case Cell64kPart:
this.idleDrain = 2.0; this.idleDrain = 2.0;
this.perType = 512; this.perType = 512;
break; break;
default: default:
this.idleDrain = 0.0; this.idleDrain = 0.0;
this.perType = 8; this.perType = 8;
} }
} }
@Override @Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation ) public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
{ {
IMEInventory<IAEItemStack> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS ); IMEInventoryHandler inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
if ( inventory instanceof ICellInventoryHandler ) if ( inventory instanceof ICellInventoryHandler )
{ {
ICellInventoryHandler handler = (ICellInventoryHandler) inventory; ICellInventoryHandler handler = ( ICellInventoryHandler ) inventory;
ICellInventory cellInventory = handler.getCellInv(); ICellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) if ( cellInventory != null )
{ {
lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + " " lines.add( cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + " "
+ cellInventory.getTotalBytes() + " " + cellInventory.getTotalBytes() + " "
+ GuiText.BytesUsed.getLocal()); + GuiText.BytesUsed.getLocal() );
lines.add(cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal() lines.add( cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal()
+ " " + cellInventory.getTotalItemTypes() + " " + " " + cellInventory.getTotalItemTypes() + " "
+ GuiText.Types.getLocal()); + GuiText.Types.getLocal() );
if ( handler.isPreformatted() ) if ( handler.isPreformatted() )
{ {
String List = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included String List = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded ).getLocal(); : GuiText.Excluded ).getLocal();
if ( handler.isFuzzy() ) if ( handler.isFuzzy() )
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Fuzzy.getLocal() ); lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Fuzzy.getLocal() );
else else
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() ); lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() );
} }
} }
} }
} }
@Override @Override
public int getBytes(ItemStack cellItem) { public int getBytes( ItemStack cellItem )
{
return this.totalBytes; return this.totalBytes;
} }
@Override @Override
public int BytePerType(ItemStack cell) public int BytePerType( ItemStack cell )
{ {
return this.perType; return this.perType;
} }
@Override @Override
public int getTotalTypes(ItemStack cellItem) public int getTotalTypes( ItemStack cellItem )
{ {
return 63; return 63;
} }
@Override @Override
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) public boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition )
{ {
return false; return false;
} }
@@ -136,7 +158,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
} }
@Override @Override
public boolean isStorageCell(ItemStack i) public boolean isStorageCell( ItemStack i )
{ {
return true; return true;
} }
@@ -148,50 +170,50 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
} }
@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 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 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 boolean isEditable(ItemStack is) public boolean isEditable( ItemStack is )
{ {
return true; return true;
} }
private boolean disassembleDrive(ItemStack stack, World world, EntityPlayer player) private boolean disassembleDrive( ItemStack stack, World world, EntityPlayer player )
{ {
if ( player.isSneaking() ) if ( player.isSneaking() )
{ {
@@ -199,7 +221,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
return false; return false;
InventoryPlayer playerInventory = player.inventory; InventoryPlayer playerInventory = player.inventory;
IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS ); IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
if ( inv != null && playerInventory.getCurrentItem() == stack ) if ( inv != null && playerInventory.getCurrentItem() == stack )
{ {
InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN ); InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
@@ -227,28 +249,27 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
{ {
disassembleDrive( stack, world, player ); disassembleDrive( stack, world, player );
return stack; return stack;
} }
@Override @Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
{ {
return disassembleDrive( stack, world, player ); return disassembleDrive( stack, world, player );
} }
@Override @Override
public boolean hasContainerItem(ItemStack stack) public boolean hasContainerItem( ItemStack stack )
{ {
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ); return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
} }
@Override @Override
public ItemStack getContainerItem(ItemStack itemStack) public ItemStack getContainerItem( ItemStack itemStack )
{ {
return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 ); return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 );
} }
} }