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
@@ -140,7 +140,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
}
}
else
{
this.recalculateDisplay();
}
}
private void recalculateDisplay()
@@ -148,12 +150,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
int oldState = this.state;
for( int x = 0; x < this.getCellCount(); x++ )
{
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
}
if( this.isPowered() )
{
this.state |= 0x40;
}
else
{
this.state &= ~0x40;
}
boolean currentActive = this.gridProxy.isActive();
if( this.wasActive != currentActive )
@@ -170,7 +178,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
}
if( oldState != this.state )
{
this.markForUpdate();
}
}
@Override
@@ -199,9 +209,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
IMEInventoryHandler<IAEFluidStack> fluidCell = this.cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS );
if( itemCell != null )
{
power += this.cellHandler.cellIdleDrain( is, itemCell );
}
else if( fluidCell != null )
{
power += this.cellHandler.cellIdleDrain( is, fluidCell );
}
this.gridProxy.setIdlePowerUsage( power );
@@ -215,11 +229,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
case FLUIDS:
if( this.fluidCell == null )
{
throw NO_HANDLER;
}
return this.fluidCell;
case ITEMS:
if( this.itemCell == null )
{
throw NO_HANDLER;
}
return this.itemCell;
default:
}
@@ -230,7 +248,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
private <StackType extends IAEStack> MEMonitorHandler<StackType> wrap( IMEInventoryHandler h )
{
if( h == null )
{
return null;
}
MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() );
ih.setPriority( this.priority );
@@ -245,7 +265,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public int getCellStatus( int slot )
{
if( Platform.isClient() )
{
return ( this.state >> ( slot * 3 ) ) & 3;
}
ItemStack cell = this.inv.getStackInSlot( 1 );
ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );
@@ -256,7 +278,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
IMEInventoryHandler handler = this.getHandler( StorageChannel.ITEMS );
if( handler instanceof ChestMonitorHandler )
{
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
}
}
catch( ChestNoHandler ignored )
{
@@ -266,7 +290,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
IMEInventoryHandler handler = this.getHandler( StorageChannel.FLUIDS );
if( handler instanceof ChestMonitorHandler )
{
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
}
}
catch( ChestNoHandler ignored )
{
@@ -280,7 +306,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public boolean isPowered()
{
if( Platform.isClient() )
{
return ( this.state & 0x40 ) == 0x40;
}
boolean gridPowered = this.getAECurrentPower() > 64;
@@ -303,7 +331,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
long now = this.worldObj.getTotalWorldTime();
if( now - this.lastStateChange > 8 )
{
return false;
}
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
}
@@ -319,7 +349,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
eg = this.gridProxy.getEnergy();
stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE );
if( stash >= amt )
{
return stash;
}
}
catch( GridAccessException e )
{
@@ -334,7 +366,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public void Tick_TileChest()
{
if( this.worldObj.isRemote )
{
return;
}
double idleUsage = this.gridProxy.getIdlePowerUsage();
@@ -344,14 +378,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
double powerUsed = this.extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 )
{
this.recalculateDisplay();
}
}
}
catch( GridAccessException e )
{
double powerUsed = this.extractAEPower( this.gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 )
{
this.recalculateDisplay();
}
}
if( this.inv.getStackInSlot( 0 ) != null )
@@ -364,17 +402,27 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public void writeToStream_TileChest( ByteBuf data )
{
if( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
{
this.state = 0;
}
else
{
this.state &= 0x24924924; // just keep the blinks...
}
for( int x = 0; x < this.getCellCount(); x++ )
{
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
}
if( this.isPowered() )
{
this.state |= 0x40;
}
else
{
this.state &= ~0x40;
}
data.writeByte( this.state );
data.writeByte( this.paintedColor.ordinal() );
@@ -404,9 +452,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
int item = data.readInt();
if( item == 0 )
{
this.storageType = null;
}
else
{
this.storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET );
}
this.lastStateChange = this.worldObj.getTotalWorldTime();
@@ -419,7 +471,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.config.readFromNBT( data );
this.priority = data.getInteger( "priority" );
if( data.hasKey( "paintedColor" ) )
{
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
}
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
@@ -503,9 +557,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
if( slotIndex == 1 )
{
if( AEApi.instance().registries().cell().getCellInventory( insertingItem, this, StorageChannel.ITEMS ) != null )
{
return true;
}
if( AEApi.instance().registries().cell().getCellInventory( insertingItem, this, StorageChannel.FLUIDS ) != null )
{
return true;
}
}
else
{
@@ -532,14 +590,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
if( ForgeDirection.SOUTH == side )
{
return FRONT;
}
if( this.isPowered() )
{
try
{
if( this.getHandler( StorageChannel.ITEMS ) != null )
{
return SIDES;
}
}
catch( ChestNoHandler e )
{
@@ -560,9 +622,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), this.mySrc );
if( returns == null )
{
this.inv.setInventorySlotContents( 0, null );
}
else
{
this.inv.setInventorySlotContents( 0, returns.getItemStack() );
}
}
}
catch( ChestNoHandler ignored )
@@ -617,7 +683,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
long now = this.worldObj.getTotalWorldTime();
if( now - this.lastStateChange > 8 )
{
this.state = 0;
}
this.lastStateChange = now;
this.state |= 1 << ( slot * 3 + 2 );
@@ -640,7 +708,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.mySrc );
if( results == null )
{
return resource.amount;
}
return resource.amount - (int) results.getStackSize();
}
@@ -690,7 +760,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
if( h.getChannel() == StorageChannel.FLUIDS )
{
return new FluidTankInfo[] { new FluidTankInfo( null, 1 ) }; // eh?
}
}
catch( ChestNoHandler ignored )
{
@@ -703,14 +775,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
{
if( Platform.canAccess( this.gridProxy, src ) && side != this.getForward() )
{
return this;
}
return null;
}
public ItemStack getStorageType()
{
if( this.isPowered() )
{
return this.storageType;
}
return null;
}
@@ -769,7 +845,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
{
if( this.paintedColor == newPaintedColor )
{
return false;
}
this.paintedColor = newPaintedColor;
this.markDirty();
@@ -803,9 +881,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public boolean isValid( Object verificationToken )
{
if( this.chan == StorageChannel.ITEMS )
{
return verificationToken == TileChest.this.itemCell;
}
if( this.chan == StorageChannel.FLUIDS )
{
return verificationToken == TileChest.this.fluidCell;
}
return false;
}
@@ -817,7 +899,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
try
{
if( TileChest.this.gridProxy.isActive() )
{
TileChest.this.gridProxy.getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc );
}
}
catch( GridAccessException e )
{
@@ -848,7 +932,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
IMEInventoryHandler<T> h = this.getHandler();
if( h instanceof MEInventoryHandler )
{
return (IMEInventoryHandler<T>) ( (MEInventoryHandler) h ).getInternal();
}
return this.getHandler();
}
@@ -856,7 +942,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public T injectItems( T input, Actionable mode, BaseActionSource src )
{
if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.INJECT ) )
{
return input;
}
return super.injectItems( input, mode, src );
}
@@ -883,7 +971,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
if( sg.hasPermission( player, requiredPermission ) )
{
return true;
}
}
}
@@ -896,7 +986,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
public T extractItems( T request, Actionable mode, BaseActionSource src )
{
if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.EXTRACT ) )
{
return null;
}
return super.extractItems( request, mode, src );
}
}
@@ -85,17 +85,27 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
public void writeToStream_TileDrive( ByteBuf data )
{
if( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
{
this.state = 0;
}
else
{
this.state &= 0x24924924; // just keep the blinks...
}
if( this.gridProxy.isActive() )
{
this.state |= 0x80000000;
}
else
{
this.state &= ~0x80000000;
}
for( int x = 0; x < this.getCellCount(); x++ )
{
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
}
data.writeInt( this.state );
}
@@ -110,25 +120,33 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
public int getCellStatus( int slot )
{
if( Platform.isClient() )
{
return ( this.state >> ( slot * 3 ) ) & 3;
}
ItemStack cell = this.inv.getStackInSlot( 2 );
ICellHandler ch = this.handlersBySlot[slot];
MEInventoryHandler handler = this.invBySlot[slot];
if( handler == null )
{
return 0;
}
if( handler.getChannel() == StorageChannel.ITEMS )
{
if( ch != null )
{
return ch.getStatusForCell( cell, handler.getInternal() );
}
}
if( handler.getChannel() == StorageChannel.FLUIDS )
{
if( ch != null )
{
return ch.getStatusForCell( cell, handler.getInternal() );
}
}
return 0;
@@ -138,7 +156,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
public boolean isPowered()
{
if( Platform.isClient() )
{
return ( this.state & 0x80000000 ) == 0x80000000;
}
return this.gridProxy.isActive();
}
@@ -148,7 +168,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
{
long now = this.worldObj.getTotalWorldTime();
if( now - this.lastStateChange > 8 )
{
return false;
}
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
}
@@ -187,9 +209,13 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
boolean currentActive = this.gridProxy.isActive();
if( currentActive )
{
this.state |= 0x80000000;
}
else
{
this.state &= ~0x80000000;
}
if( this.wasActive != currentActive )
{
@@ -205,10 +231,14 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
for( int x = 0; x < this.getCellCount(); x++ )
{
this.state |= ( this.getCellStatus( x ) << ( 3 * x ) );
}
if( oldState != this.state )
{
this.markForUpdate();
}
}
@MENetworkEventSubscribe
@@ -374,7 +404,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
{
long now = this.worldObj.getTotalWorldTime();
if( now - this.lastStateChange > 8 )
{
this.state = 0;
}
this.lastStateChange = now;
this.state |= 1 << ( slot * 3 + 2 );
@@ -135,7 +135,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
this.cells.readFromNBT( data, "cells" );
this.upgrades.readFromNBT( data, "upgrades" );
if( data.hasKey( "lastRedstoneState" ) )
{
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
}
}
@Override
@@ -155,9 +157,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
try
{
if( this.hasWork() )
{
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
}
else
{
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
}
}
catch( GridAccessException e )
{
@@ -178,7 +184,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
public boolean getRedstoneState()
{
if( this.lastRedstoneState == YesNo.UNDECIDED )
{
this.updateRedstoneState();
}
return this.lastRedstoneState == YesNo.YES;
}
@@ -186,11 +194,15 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
private boolean isEnabled()
{
if( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 )
{
return true;
}
RedstoneMode rs = (RedstoneMode) this.manager.getSetting( Settings.REDSTONE_CONTROLLED );
if( rs == RedstoneMode.HIGH_SIGNAL )
{
return this.getRedstoneState();
}
return !this.getRedstoneState();
}
@@ -204,10 +216,14 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
public IInventory getInventoryByName( String name )
{
if( name.equals( "upgrades" ) )
{
return this.upgrades;
}
if( name.equals( "cells" ) )
{
return this.cells;
}
return null;
}
@@ -223,8 +239,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if( this.isEnabled() )
{
for( int x = 0; x < 6; x++ )
{
if( this.cells.getStackInSlot( x ) != null )
{
return true;
}
}
}
return false;
@@ -277,7 +297,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
public int[] getAccessibleSlotsBySide( ForgeDirection d )
{
if( d == ForgeDirection.UP || d == ForgeDirection.DOWN )
{
return this.input;
}
return this.output;
}
@@ -292,7 +314,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
{
if( !this.gridProxy.isActive() )
{
return TickRateModulation.IDLE;
}
long ItemsToMove = 256;
@@ -327,25 +351,37 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
{
if( itemInv != null )
{
ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS );
}
if( fluidInv != null )
{
ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS );
}
}
else
{
if( itemInv != null )
{
ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS );
}
if( fluidInv != null )
{
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS );
}
}
if( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) )
{
return TickRateModulation.IDLE;
}
return TickRateModulation.URGENT;
}
else
{
return TickRateModulation.URGENT;
}
}
}
}
@@ -374,7 +410,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
if( StorageChannel.ITEMS == chan )
{
return this.cachedItem;
}
return this.cachedFluid;
}
@@ -383,9 +421,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
{
IItemList<? extends IAEStack> myList;
if( src instanceof IMEMonitor )
{
myList = ( (IMEMonitor) src ).getStorageList();
}
else
{
myList = src.getAvailableItems( src.getChannel().createList() );
}
boolean didStuff;
@@ -402,9 +444,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
long possible = 0;
if( stack == null )
{
possible = totalStackSize;
}
else
{
possible = totalStackSize - stack.getStackSize();
}
if( possible > 0 )
{
@@ -445,11 +491,17 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE );
if( itemInv != null && fluidInv != null )
{
return this.matches( fm, itemInv ) && this.matches( fm, fluidInv );
}
else if( itemInv != null )
{
return this.matches( fm, itemInv );
}
else if( fluidInv != null )
{
return this.matches( fm, fluidInv );
}
return true;
}
@@ -471,17 +523,25 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
private boolean matches( FullnessMode fm, IMEInventory src )
{
if( fm == FullnessMode.HALF )
{
return true;
}
IItemList<? extends IAEStack> myList;
if( src instanceof IMEMonitor )
{
myList = ( (IMEMonitor) src ).getStorageList();
}
else
{
myList = src.getAvailableItems( src.getChannel().createList() );
}
if( fm == FullnessMode.EMPTY )
{
return myList.isEmpty();
}
IAEStack test = myList.getFirstItem();
if( test != null )
@@ -57,7 +57,9 @@ public class TileSkyChest extends AEBaseInvTile
this.playerOpen = data.readBoolean() ? 1 : 0;
if( wasOpen != this.playerOpen )
{
this.lastEvent = System.currentTimeMillis();
}
return false; // TESR yo!
}
@@ -78,7 +80,9 @@ public class TileSkyChest extends AEBaseInvTile
public void openInventory()
{
if( Platform.isClient() )
{
return;
}
this.playerOpen++;
@@ -93,12 +97,16 @@ public class TileSkyChest extends AEBaseInvTile
public void closeInventory()
{
if( Platform.isClient() )
{
return;
}
this.playerOpen--;
if( this.playerOpen < 0 )
{
this.playerOpen = 0;
}
if( this.playerOpen == 0 )
{