Use correct return type as variable
Added copyright Reformat code Rearrange code
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -10,6 +29,7 @@ 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.config.IncludeExclude;
|
||||
@@ -17,7 +37,7 @@ import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -31,15 +51,16 @@ import appeng.items.materials.MaterialType;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
|
||||
{
|
||||
|
||||
final MaterialType component;
|
||||
final int totalBytes;
|
||||
final int perType;
|
||||
final double idleDrain;
|
||||
|
||||
public ItemBasicStorageCell(MaterialType whichCell, int Kilobytes) {
|
||||
public ItemBasicStorageCell( MaterialType whichCell, int Kilobytes )
|
||||
{
|
||||
super( ItemBasicStorageCell.class, Kilobytes + "k" );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
|
||||
@@ -47,84 +68,85 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
this.totalBytes = Kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
|
||||
switch (this.component)
|
||||
switch ( this.component )
|
||||
{
|
||||
case Cell1kPart:
|
||||
this.idleDrain = 0.5;
|
||||
this.perType = 8;
|
||||
break;
|
||||
case Cell4kPart:
|
||||
this.idleDrain = 1.0;
|
||||
this.perType = 32;
|
||||
break;
|
||||
case Cell16kPart:
|
||||
this.idleDrain = 1.5;
|
||||
this.perType = 128;
|
||||
break;
|
||||
case Cell64kPart:
|
||||
this.idleDrain = 2.0;
|
||||
this.perType = 512;
|
||||
break;
|
||||
default:
|
||||
this.idleDrain = 0.0;
|
||||
this.perType = 8;
|
||||
case Cell1kPart:
|
||||
this.idleDrain = 0.5;
|
||||
this.perType = 8;
|
||||
break;
|
||||
case Cell4kPart:
|
||||
this.idleDrain = 1.0;
|
||||
this.perType = 32;
|
||||
break;
|
||||
case Cell16kPart:
|
||||
this.idleDrain = 1.5;
|
||||
this.perType = 128;
|
||||
break;
|
||||
case Cell64kPart:
|
||||
this.idleDrain = 2.0;
|
||||
this.perType = 512;
|
||||
break;
|
||||
default:
|
||||
this.idleDrain = 0.0;
|
||||
this.perType = 8;
|
||||
}
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
ICellInventoryHandler handler = (ICellInventoryHandler) inventory;
|
||||
ICellInventoryHandler handler = ( ICellInventoryHandler ) inventory;
|
||||
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() + " "
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
|
||||
lines.add(cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal()
|
||||
+ GuiText.BytesUsed.getLocal() );
|
||||
|
||||
lines.add( cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal()
|
||||
+ " " + cellInventory.getTotalItemTypes() + " "
|
||||
+ GuiText.Types.getLocal());
|
||||
|
||||
+ GuiText.Types.getLocal() );
|
||||
|
||||
if ( handler.isPreformatted() )
|
||||
{
|
||||
String List = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
|
||||
: GuiText.Excluded ).getLocal();
|
||||
|
||||
String List = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
|
||||
: GuiText.Excluded ).getLocal();
|
||||
|
||||
if ( handler.isFuzzy() )
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Fuzzy.getLocal() );
|
||||
else
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() );
|
||||
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + List + " " + GuiText.Precise.getLocal() );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(ItemStack cellItem) {
|
||||
public int getBytes( ItemStack cellItem )
|
||||
{
|
||||
return this.totalBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int BytePerType(ItemStack cell)
|
||||
public int BytePerType( ItemStack cell )
|
||||
{
|
||||
return this.perType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem)
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition)
|
||||
public boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +158,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i)
|
||||
public boolean isStorageCell( ItemStack i )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -148,50 +170,50 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is)
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is)
|
||||
public IInventory getConfigInventory( ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is)
|
||||
public FuzzyMode getFuzzyMode( ItemStack is )
|
||||
{
|
||||
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch ( Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName(Set<ItemStack> others, ItemStack is)
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is)
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean disassembleDrive(ItemStack stack, World world, EntityPlayer player)
|
||||
private boolean disassembleDrive( ItemStack stack, World world, EntityPlayer player )
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
@@ -199,7 +221,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
return false;
|
||||
|
||||
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 )
|
||||
{
|
||||
InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
|
||||
@@ -227,28 +249,27 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
|
||||
{
|
||||
disassembleDrive( stack, world, player );
|
||||
return stack;
|
||||
}
|
||||
|
||||
@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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
public boolean hasContainerItem( ItemStack stack )
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
public ItemStack getContainerItem( ItemStack itemStack )
|
||||
{
|
||||
return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user