Puts everywhere brackets

This commit is contained in:
thatsIch
2015-04-29 02:30:53 +02:00
parent 23aa8fd72d
commit 64ed05a1b4
465 changed files with 6726 additions and 14 deletions
@@ -40,7 +40,9 @@ public class AEExternalHandler implements IExternalStorageHandler
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc )
{
if( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable )
{
return ( (ITileStorageMonitorable) te ).getMonitorable( d, mySrc ) != null;
}
return te instanceof TileCondenser;
}
@@ -51,9 +53,13 @@ public class AEExternalHandler implements IExternalStorageHandler
if( te instanceof TileCondenser )
{
if( channel == StorageChannel.ITEMS )
{
return new VoidItemInventory( (TileCondenser) te );
}
else
{
return new VoidFluidInventory( (TileCondenser) te );
}
}
if( te instanceof ITileStorageMonitorable )
@@ -65,14 +71,18 @@ public class AEExternalHandler implements IExternalStorageHandler
{
IMEInventory<IAEItemStack> ii = sm.getItemInventory();
if( ii != null )
{
return ii;
}
}
if( channel == StorageChannel.FLUIDS && sm != null )
{
IMEInventory<IAEFluidStack> fi = sm.getFluidInventory();
if( fi != null )
{
return fi;
}
}
}
@@ -114,9 +114,13 @@ public class CellInventory implements ICellInventory
}
if( this.MAX_ITEM_TYPES > 63 )
{
this.MAX_ITEM_TYPES = 63;
}
if( this.MAX_ITEM_TYPES < 1 )
{
this.MAX_ITEM_TYPES = 1;
}
this.container = container;
this.tagCompound = Platform.openNbtData( o );
@@ -184,7 +188,9 @@ public class CellInventory implements ICellInventory
public static boolean isBlackListed( IAEItemStack input )
{
if( BLACK_LIST.contains( ( OreDictionary.WILDCARD_VALUE << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ) )
{
return true;
}
return BLACK_LIST.contains( ( input.getItemDamage() << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) );
}
@@ -197,12 +203,18 @@ public class CellInventory implements ICellInventory
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( input == null )
{
return null;
}
if( input.getStackSize() == 0 )
{
return null;
}
if( isBlackListed( input ) || this.CellType.isBlackListed( this.i, input ) )
{
return input;
}
ItemStack sharedItemStack = input.getItemStack();
@@ -210,7 +222,9 @@ public class CellInventory implements ICellInventory
{
IMEInventory meInventory = getCell( sharedItemStack, null );
if( meInventory != null && !this.isEmpty( meInventory ) )
{
return input;
}
}
IAEItemStack l = this.getCellItems().findPrecise( input );
@@ -218,7 +232,9 @@ public class CellInventory implements ICellInventory
{
long remainingItemSlots = this.getRemainingItemCount();
if( remainingItemSlots < 0 )
{
return input;
}
if( input.getStackSize() > remainingItemSlots )
{
@@ -284,7 +300,9 @@ public class CellInventory implements ICellInventory
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if( request == null )
{
return null;
}
long size = Math.min( Integer.MAX_VALUE, request.getStackSize() );
@@ -408,13 +426,17 @@ public class CellInventory implements ICellInventory
}
if( this.container != null )
{
this.container.saveChanges( this );
}
}
protected void loadCellItems()
{
if( this.cellItems == null )
{
this.cellItems = AEApi.instance().storage().createItemList();
}
this.cellItems.resetStatus(); // clears totals and stuff.
@@ -441,7 +463,9 @@ public class CellInventory implements ICellInventory
public IItemList getAvailableItems( IItemList out )
{
for( IAEItemStack i : this.getCellItems() )
{
out.add( i );
}
return out;
}
@@ -564,9 +588,13 @@ public class CellInventory implements ICellInventory
public int getStatusForCell()
{
if( this.canHoldNewItem() )
{
return 1;
}
if( this.getRemainingItemCount() > 0 )
{
return 2;
}
return 3;
}
}
@@ -85,7 +85,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
{
ItemStack is = config.getStackInSlot( x );
if( is != null )
{
priorityList.add( AEItemStack.create( is ) );
}
}
this.setWhitelist( hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
@@ -93,9 +95,13 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
if( !priorityList.isEmpty() )
{
if( hasFuzzy )
{
this.setPartitionList( new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode ) );
}
else
{
this.setPartitionList( new PrecisePriorityList<IAEItemStack>( priorityList ) );
}
}
}
}
@@ -106,7 +112,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
Object o = this.internal;
if( o instanceof MEPassThrough )
{
o = ( (MEPassThrough) o ).getInternal();
}
return (ICellInventory) ( o instanceof ICellInventory ? o : null );
}
@@ -139,7 +147,9 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
int val = this.getCellInv().getStatusForCell();
if( val == 1 && this.isPreformatted() )
{
val = 2;
}
return val;
}
@@ -42,12 +42,14 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
CellConfig cc = new CellConfig( o );
for( ItemStack is : cc )
{
if( is != null )
{
IAEItemStack i = AEItemStack.create( is );
i.setStackSize( Integer.MAX_VALUE );
this.itemListCache.add( i );
}
}
}
public static IMEInventoryHandler getCell( ItemStack o )
@@ -60,7 +62,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
IAEItemStack local = this.itemListCache.findPrecise( input );
if( local == null )
{
return input;
}
return null;
}
@@ -70,7 +74,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{
IAEItemStack local = this.itemListCache.findPrecise( request );
if( local == null )
{
return null;
}
return request.copy();
}
@@ -79,7 +85,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( IAEItemStack ais : this.itemListCache )
{
out.add( ais );
}
return out;
}
@@ -90,7 +90,9 @@ public class ItemWatcher implements IStackWatcher
public boolean add( IAEStack e )
{
if( this.myInterests.contains( e ) )
{
return false;
}
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
}
@@ -113,7 +115,9 @@ public class ItemWatcher implements IStackWatcher
boolean didChange = false;
for( IAEStack o : c )
{
didChange = this.add( o ) || didChange;
}
return didChange;
}
@@ -123,7 +127,9 @@ public class ItemWatcher implements IStackWatcher
{
boolean didSomething = false;
for( Object o : c )
{
didSomething = this.remove( o ) || didSomething;
}
return didSomething;
}
@@ -54,7 +54,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
{
ItemStack is = mode == Actionable.SIMULATE ? this.adaptor.simulateAdd( input ) : this.adaptor.addItems( input );
if( is == null )
{
return null;
}
return AEItemStack.create( is );
}
@@ -109,7 +111,9 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
out.stackSize -= t.stackSize;
if( mode == Actionable.MODULATE )
{
this.target.setInventorySlotContents( x, t );
}
if( out.stackSize <= 0 )
{
@@ -172,9 +176,13 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
}
if( sub.stackSize <= 0 )
{
this.target.setInventorySlotContents( x, null );
}
else
{
this.target.setInventorySlotContents( x, sub );
}
if( retrieved != null )
{
@@ -53,9 +53,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
this.channel = channel;
if( i instanceof IMEInventoryHandler )
{
this.internal = (IMEInventoryHandler<T>) i;
}
else
{
this.internal = new MEPassThrough<T>( i, channel );
}
this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor<T>) this.internal : null;
@@ -102,7 +106,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public T injectItems( T input, Actionable type, BaseActionSource src )
{
if( !this.canAccept( input ) )
{
return input;
}
return this.internal.injectItems( input, type, src );
}
@@ -111,7 +117,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public T extractItems( T request, Actionable type, BaseActionSource src )
{
if( !this.hasReadAccess )
{
return null;
}
return this.internal.extractItems( request, type, src );
}
@@ -120,7 +128,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public IItemList<T> getAvailableItems( IItemList<T> out )
{
if( !this.hasReadAccess )
{
return out;
}
return this.internal.getAvailableItems( out );
}
@@ -141,7 +151,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public boolean isPrioritized( T input )
{
if( this.myWhitelist == IncludeExclude.WHITELIST )
{
return this.myPartitionList.isListed( input ) || this.internal.isPrioritized( input );
}
return false;
}
@@ -149,12 +161,18 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public boolean canAccept( T input )
{
if( !this.hasWriteAccess )
{
return false;
}
if( this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed( input ) )
{
return false;
}
if( this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST )
{
return this.internal.canAccept( input );
}
return this.myPartitionList.isListed( input ) && this.internal.canAccept( input );
}
@@ -78,14 +78,20 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
ItemStack out = null;
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateAdd( input.getItemStack() );
}
else
{
out = this.adaptor.addItems( input.getItemStack() );
}
this.onTick();
if( out == null )
{
return null;
}
// better then doing construction from scratch :3
IAEItemStack o = input.copy();
@@ -99,12 +105,18 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
ItemStack out = null;
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null );
}
else
{
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
}
if( out == null )
{
return null;
}
// better then doing construction from scratch :3
IAEItemStack o = request.copy();
@@ -199,7 +211,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
}
if( !changes.isEmpty() )
{
this.postDifference( changes );
}
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
}
@@ -207,10 +221,14 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
private boolean isDifferent( ItemStack a, ItemStack b )
{
if( a == b && b == null )
{
return false;
}
if( ( a == null && b != null ) || ( a != null && b == null ) )
{
return true;
}
return !Platform.isSameItemPrecise( a, b );
}
@@ -226,9 +244,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
if( key.isValid( l.getValue() ) )
{
key.postChange( this, a, this.mySource );
}
else
{
i.remove();
}
}
}
}
@@ -273,7 +295,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( CachedItemStack is : this.memory.values() )
{
out.addStorage( is.aeStack );
}
return out;
}
@@ -46,26 +46,34 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
{
super( i, channel );
if( i instanceof IMEMonitor )
{
this.monitor = (IMEMonitor<T>) i;
}
}
@Override
public void setInternal( IMEInventory<T> i )
{
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
this.monitor = null;
IItemList<T> before = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
super.setInternal( i );
if( i instanceof IMEMonitor )
{
this.monitor = (IMEMonitor<T>) i;
}
IItemList<T> after = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) );
if( this.monitor != null )
{
this.monitor.addListener( this, this.monitor );
}
Platform.postListChanges( before, after, this, this.changeSource );
}
@@ -116,9 +124,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
IMEMonitorHandlerReceiver<T> receiver = e.getKey();
if( receiver.isValid( e.getValue() ) )
{
receiver.postChange( this, change, source );
}
else
{
i.remove();
}
}
}
@@ -131,9 +143,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
Entry<IMEMonitorHandlerReceiver<T>, Object> e = i.next();
IMEMonitorHandlerReceiver<T> receiver = e.getKey();
if( receiver.isValid( e.getValue() ) )
{
receiver.onListUpdate();
}
else
{
i.remove();
}
}
}
}
@@ -77,7 +77,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
int priority = h.getPriority();
List<IMEInventoryHandler<T>> list = this.priorityInventory.get( priority );
if( list == null )
{
this.priorityInventory.put( priority, list = new ArrayList<IMEInventoryHandler<T>>() );
}
list.add( h );
}
@@ -86,7 +88,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public T injectItems( T input, Actionable type, BaseActionSource src )
{
if( this.diveList( this, type ) )
{
return input;
}
if( this.testPermission( src, SecurityPermissions.INJECT ) )
{
@@ -127,7 +131,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{
LinkedList cDepth = this.getDepth( type );
if( cDepth.contains( networkInventoryHandler ) )
{
return true;
}
cDepth.push( this );
return false;
@@ -138,7 +144,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
if( src.isPlayer() )
{
if( !this.security.hasPermission( ( (PlayerSource) src ).player, permission ) )
{
return true;
}
}
else if( src.isMachine() )
{
@@ -146,7 +154,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{
IGridNode n = ( (MachineSource) src ).via.getActionableNode();
if( n == null )
{
return true;
}
IGrid gn = n.getGrid();
if( gn != this.security.myGrid )
@@ -157,7 +167,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
playerID = sg.getOwner();
if( !this.security.hasPermission( playerID, permission ) )
{
return true;
}
}
}
}
@@ -168,7 +180,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
private void surface( NetworkInventoryHandler<T> networkInventoryHandler, Actionable type )
{
if( this.getDepth( type ).pop() != this )
{
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
}
}
private LinkedList getDepth( Actionable type )
@@ -178,7 +192,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
LinkedList s = depth.get();
if( s == null )
{
depth.set( s = new LinkedList() );
}
return s;
}
@@ -187,7 +203,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public T extractItems( T request, Actionable mode, BaseActionSource src )
{
if( this.diveList( this, mode ) )
{
return null;
}
if( this.testPermission( src, SecurityPermissions.EXTRACT ) )
{
@@ -219,7 +237,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
this.surface( this, mode );
if( output.getStackSize() <= 0 )
{
return null;
}
return output;
}
@@ -228,12 +248,18 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
public IItemList<T> getAvailableItems( IItemList out )
{
if( this.diveIteration( this, Actionable.SIMULATE ) )
{
return out;
}
// for (Entry<Integer, IMEInventoryHandler<T>> h : priorityInventory.entries())
for( List<IMEInventoryHandler<T>> i : this.priorityInventory.values() )
{
for( IMEInventoryHandler<T> j : i )
{
out = j.getAvailableItems( out );
}
}
this.surface( this, Actionable.SIMULATE );
@@ -251,9 +277,13 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
else
{
if( currentPass == this.myPass )
{
return true;
}
else
{
this.myPass = currentPass;
}
}
cDepth.push( this );
@@ -57,7 +57,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
if( this.canAccept( input ) )
{
if( type == Actionable.SIMULATE )
{
return null;
}
this.storedItems.add( input );
this.securityTile.inventoryChanged();
@@ -95,7 +97,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
IAEItemStack output = target.copy();
if( mode == Actionable.SIMULATE )
{
return output;
}
target.setStackSize( 0 );
this.securityTile.inventoryChanged();
@@ -109,7 +113,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
for( IAEItemStack ais : this.storedItems )
{
out.add( ais );
}
return out;
}
@@ -142,7 +148,9 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
int PlayerID = AEApi.instance().registries().players().getID( newUser );
if( this.securityTile.getOwner() == PlayerID )
{
return false;
}
for( IAEItemStack ais : this.storedItems )
{
@@ -150,10 +158,14 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
GameProfile thisUser = tbc.getProfile( ais.getItemStack() );
if( thisUser == newUser )
{
return false;
}
if( thisUser != null && thisUser.equals( newUser ) )
{
return false;
}
}
}
@@ -43,10 +43,14 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
public IAEFluidStack injectItems( IAEFluidStack input, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
return null;
}
if( input != null )
{
this.target.addPower( input.getStackSize() / 1000.0 );
}
return null;
}
@@ -43,10 +43,14 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( mode == Actionable.SIMULATE )
{
return null;
}
if( input != null )
{
this.target.addPower( input.getStackSize() );
}
return null;
}