Annotated IStorageCell with Nonnull where appropriate.
This commit is contained in:
@@ -24,6 +24,8 @@
|
|||||||
package appeng.api.implementations.items;
|
package appeng.api.implementations.items;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import appeng.api.storage.ICellWorkbenchItem;
|
import appeng.api.storage.ICellWorkbenchItem;
|
||||||
@@ -52,7 +54,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
*
|
*
|
||||||
* @return number of bytes
|
* @return number of bytes
|
||||||
*/
|
*/
|
||||||
int getBytes( ItemStack cellItem );
|
int getBytes( @Nonnull ItemStack cellItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the number of bytes used for any type included on the cell.
|
* Determines the number of bytes used for any type included on the cell.
|
||||||
@@ -61,7 +63,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
*
|
*
|
||||||
* @return number of bytes
|
* @return number of bytes
|
||||||
*/
|
*/
|
||||||
int getBytesPerType( ItemStack cellItem );
|
int getBytesPerType( @Nonnull ItemStack cellItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be between 1 and 63, indicates how many types you want to store on
|
* Must be between 1 and 63, indicates how many types you want to store on
|
||||||
@@ -71,7 +73,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
*
|
*
|
||||||
* @return number of types
|
* @return number of types
|
||||||
*/
|
*/
|
||||||
int getTotalTypes( ItemStack cellItem );
|
int getTotalTypes( @Nonnull ItemStack cellItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to fine tune which items are allowed on a given cell, if you
|
* Allows you to fine tune which items are allowed on a given cell, if you
|
||||||
@@ -83,7 +85,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
*
|
*
|
||||||
* @return true to preventAdditionOfItem
|
* @return true to preventAdditionOfItem
|
||||||
*/
|
*/
|
||||||
boolean isBlackListed( ItemStack cellItem, T requestedAddition );
|
boolean isBlackListed( @Nonnull ItemStack cellItem, @Nonnull T requestedAddition );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to specify if this storage cell can be stored inside other
|
* Allows you to specify if this storage cell can be stored inside other
|
||||||
@@ -104,7 +106,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
*
|
*
|
||||||
* @return if the ItemStack should behavior as a storage cell.
|
* @return if the ItemStack should behavior as a storage cell.
|
||||||
*/
|
*/
|
||||||
boolean isStorageCell( ItemStack i );
|
boolean isStorageCell( @Nonnull ItemStack i );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return drain in ae/t this storage cell will use.
|
* @return drain in ae/t this storage cell will use.
|
||||||
@@ -114,5 +116,6 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
|
|||||||
/**
|
/**
|
||||||
* @return the type of channel your cell should be part of
|
* @return the type of channel your cell should be part of
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
IStorageChannel<T> getChannel();
|
IStorageChannel<T> getChannel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,52 +64,44 @@ public class BasicCellInventory<T extends IAEStack<T>> extends AbstractCellInven
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends AEStack<T>> boolean isCellOfType( final ItemStack input, IStorageChannel channel )
|
public static <T extends AEStack<T>> boolean isCellOfType( final ItemStack input, IStorageChannel<?> channel )
|
||||||
{
|
{
|
||||||
if( input == null )
|
final IStorageCell<?> type = getStorageCell( input );
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Item type = input.getItem();
|
return type != null && type.getChannel() == channel;
|
||||||
if( type instanceof IStorageCell )
|
|
||||||
{
|
|
||||||
return ( (IStorageCell) type ).getChannel() == channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCell( final ItemStack input )
|
public static boolean isCell( final ItemStack input )
|
||||||
{
|
{
|
||||||
if( input == null )
|
return getStorageCell( input ) != null;
|
||||||
{
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
private boolean isStorageCell( final T input )
|
||||||
|
{
|
||||||
|
if( input instanceof IAEItemStack )
|
||||||
{
|
{
|
||||||
final Item type = input.getItem();
|
final IAEItemStack stack = (IAEItemStack) input;
|
||||||
if( type instanceof IStorageCell )
|
final IStorageCell<?> type = getStorageCell( stack.getDefinition() );
|
||||||
{
|
|
||||||
return !( (IStorageCell) type ).storableInStorageCell();
|
return type != null && !type.storableInStorageCell();
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final Throwable err )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStorageCell( final T input )
|
private static IStorageCell<?> getStorageCell( final ItemStack input )
|
||||||
{
|
{
|
||||||
if( !input.isItem() )
|
if( input != null )
|
||||||
{
|
{
|
||||||
return false;
|
final Item type = input.getItem();
|
||||||
|
|
||||||
|
if( type instanceof IStorageCell )
|
||||||
|
{
|
||||||
|
return (IStorageCell<?>) type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return isCell( ( (IAEItemStack) input ).getDefinition() );
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||||
|
|||||||
Reference in New Issue
Block a user