Puts everywhere brackets
This commit is contained in:
@@ -60,7 +60,9 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack is = this.getStackInSlot( x );
|
||||
if( is != null )
|
||||
{
|
||||
is.writeToNBT( item );
|
||||
}
|
||||
opt.setTag( "item" + x, item );
|
||||
}
|
||||
data.setTag( "inv", opt );
|
||||
|
||||
@@ -93,7 +93,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
ItemStackSrc src = ITEM_STACKS.get( obj.getClass() );
|
||||
if( src == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return src.stack( 1 );
|
||||
}
|
||||
|
||||
@@ -108,7 +110,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
public void onChunkLoad()
|
||||
{
|
||||
if( this.isInvalid() )
|
||||
{
|
||||
this.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,9 +122,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
super.readFromNBT( data );
|
||||
|
||||
if( data.hasKey( "customName" ) )
|
||||
{
|
||||
this.customName = data.getString( "customName" );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.customName = null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -153,17 +161,23 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
|
||||
if( this.customName != null )
|
||||
{
|
||||
data.setString( "customName", this.customName );
|
||||
}
|
||||
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ) )
|
||||
{
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void updateEntity()
|
||||
{
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) )
|
||||
{
|
||||
h.Tick( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,7 +191,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
this.writeToStream( stream );
|
||||
if( stream.readableBytes() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
@@ -209,7 +225,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
ByteBuf stream = Unpooled.copiedBuffer( pkt.func_148857_g().getByteArray( "X" ) );
|
||||
if( this.readFromStream( stream ) )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +235,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
public void onChunkUnload()
|
||||
{
|
||||
if( !this.isInvalid() )
|
||||
{
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean readFromStream( ByteBuf data )
|
||||
@@ -241,11 +261,17 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
|
||||
this.renderFragment = 100;
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ) )
|
||||
{
|
||||
if( h.readFromStream( this, data ) )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
this.renderFragment = 0;
|
||||
}
|
||||
catch( Throwable t )
|
||||
@@ -259,7 +285,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
public void markForUpdate()
|
||||
{
|
||||
if( this.renderFragment > 0 )
|
||||
{
|
||||
this.renderFragment |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Optimize Network Load
|
||||
@@ -282,7 +310,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
|
||||
for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ) )
|
||||
{
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
@@ -323,7 +353,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
List<AETileEventHandler> list = handlerSet.get( type );
|
||||
|
||||
if( list == null )
|
||||
{
|
||||
handlerSet.put( type, list = new LinkedList<AETileEventHandler>() );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -333,7 +365,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
|
||||
if( list == null )
|
||||
{
|
||||
handlerSet.put( value, list = new ArrayList<AETileEventHandler>() );
|
||||
}
|
||||
|
||||
list.add( new AETileEventHandler( m, value ) );
|
||||
}
|
||||
@@ -379,7 +413,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager();
|
||||
if( cm != null )
|
||||
{
|
||||
cm.readFromNBT( compound );
|
||||
}
|
||||
}
|
||||
|
||||
if( this instanceof IPriorityHost )
|
||||
@@ -397,7 +433,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for( int x = 0; x < tmp.getSizeInventory(); x++ )
|
||||
{
|
||||
target.setInventorySlotContents( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -422,7 +460,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( l );
|
||||
if( is != null )
|
||||
{
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,7 +499,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager();
|
||||
if( cm != null )
|
||||
{
|
||||
cm.writeToNBT( output );
|
||||
}
|
||||
}
|
||||
|
||||
if( this instanceof IPriorityHost )
|
||||
|
||||
@@ -59,9 +59,13 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
boolean hasItem = data.readBoolean();
|
||||
|
||||
if( hasItem )
|
||||
{
|
||||
this.dspPlay = AEItemStack.loadItemStackFromPacket( data );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dspPlay = null;
|
||||
}
|
||||
|
||||
this.updateList = true;
|
||||
return oldPaintedColor != this.paintedColor; // tesr!
|
||||
@@ -73,7 +77,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
if( this.dspPlay == null )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
@@ -85,7 +91,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
public void readFromNBT_TileCraftingMonitorTile( NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
@@ -144,7 +152,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.markDirty();
|
||||
|
||||
@@ -76,7 +76,9 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
||||
public int getStorageBytes()
|
||||
{
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 )
|
||||
{
|
||||
|
||||
@@ -101,13 +101,17 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
super.setName( name );
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.updateName();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAccelerator()
|
||||
{
|
||||
if( this.worldObj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) == 1;
|
||||
}
|
||||
|
||||
@@ -127,7 +131,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void updateStatus( CraftingCPUCluster c )
|
||||
{
|
||||
if( this.cluster != null && this.cluster != c )
|
||||
{
|
||||
this.cluster.breakCluster();
|
||||
}
|
||||
|
||||
this.cluster = c;
|
||||
this.updateMeta( true );
|
||||
@@ -136,33 +142,45 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void updateMeta( boolean updateFormed )
|
||||
{
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean formed = this.isFormed();
|
||||
boolean power = false;
|
||||
|
||||
if( this.gridProxy.isReady() )
|
||||
{
|
||||
power = this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
int current = this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
|
||||
int newMeta = ( current & 3 ) | ( formed ? 8 : 0 ) | ( power ? 4 : 0 );
|
||||
|
||||
if( current != newMeta )
|
||||
{
|
||||
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, newMeta, 2 );
|
||||
}
|
||||
|
||||
if( updateFormed )
|
||||
{
|
||||
if( formed )
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFormed()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8 ) == 8;
|
||||
}
|
||||
return this.cluster != null;
|
||||
}
|
||||
|
||||
@@ -171,7 +189,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
data.setBoolean( "core", this.isCoreBlock );
|
||||
if( this.isCoreBlock && this.cluster != null )
|
||||
{
|
||||
this.cluster.writeToNBT( data );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
@@ -181,9 +201,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
if( this.isCoreBlock )
|
||||
{
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.readFromNBT( data );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.previousState = (NBTTagCompound) data.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +218,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
this.cluster.destroy();
|
||||
if( update )
|
||||
{
|
||||
this.updateMeta( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +277,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
IGridHost h = i.next();
|
||||
if( h == this )
|
||||
{
|
||||
places.add( new WorldCoord( this ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity te = (TileEntity) h;
|
||||
@@ -261,7 +289,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
WorldCoord wc = new WorldCoord( te );
|
||||
wc.add( d, 1 );
|
||||
if( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
|
||||
{
|
||||
places.add( wc );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,7 +299,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
Collections.shuffle( places );
|
||||
|
||||
if( places.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." );
|
||||
}
|
||||
|
||||
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
{
|
||||
@@ -279,7 +311,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
{
|
||||
IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() );
|
||||
if( g == null )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
WorldCoord wc = places.poll();
|
||||
places.add( wc );
|
||||
@@ -296,7 +330,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4;
|
||||
}
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@@ -304,7 +340,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public boolean isActive()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
return this.isPowered() && this.isFormed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
{
|
||||
boolean isEmpty = true;
|
||||
for( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
{
|
||||
isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty;
|
||||
}
|
||||
|
||||
if( isEmpty && patternDetails.isCraftable() )
|
||||
{
|
||||
@@ -128,7 +130,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
this.pushDirection = where;
|
||||
|
||||
for( int x = 0; x < table.getSizeInventory(); x++ )
|
||||
{
|
||||
this.inv.setInventorySlotContents( x, table.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
this.updateSleepiness();
|
||||
this.markDirty();
|
||||
@@ -147,9 +151,13 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
try
|
||||
{
|
||||
if( this.isAwake )
|
||||
{
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
@@ -166,10 +174,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
private boolean hasMats()
|
||||
{
|
||||
if( this.myPlan == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
{
|
||||
this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
return this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ) != null;
|
||||
}
|
||||
@@ -252,7 +264,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
this.reboot = true;
|
||||
|
||||
if( this.forcePlan )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack is = this.inv.getStackInSlot( 10 );
|
||||
|
||||
@@ -306,10 +320,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if( name.equals( "upgrades" ) )
|
||||
{
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
if( name.equals( "mac" ) )
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -336,10 +354,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if( i >= 9 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.hasPattern() )
|
||||
{
|
||||
return this.myPlan.isValidItemForSlot( i, itemstack, this.getWorldObj() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -353,7 +375,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( inv == this.inv )
|
||||
{
|
||||
this.recalculatePlan();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,7 +406,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if( is != null )
|
||||
{
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +429,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
|
||||
// did it eject?
|
||||
if( this.inv.getStackInSlot( 9 ) == null )
|
||||
{
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
this.ejectHeldItems();
|
||||
this.updateSleepiness();
|
||||
@@ -418,10 +446,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
}
|
||||
|
||||
if( this.reboot )
|
||||
{
|
||||
TicksSinceLastCall = 1;
|
||||
}
|
||||
|
||||
if( !this.isAwake )
|
||||
{
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
this.reboot = false;
|
||||
int speed = 10;
|
||||
@@ -450,7 +482,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
if( this.progress >= 100 )
|
||||
{
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
{
|
||||
this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
this.progress = 0;
|
||||
ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorldObj() );
|
||||
@@ -461,7 +495,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
this.pushOut( output.copy() );
|
||||
|
||||
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
{
|
||||
this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) );
|
||||
}
|
||||
|
||||
if( this.inv.getStackInSlot( 10 ) == null )
|
||||
{
|
||||
@@ -530,10 +566,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
if( this.pushDirection == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
output = this.pushTo( output, d );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output = this.pushTo( output, this.pushDirection );
|
||||
}
|
||||
|
||||
if( output == null && this.forcePlan )
|
||||
{
|
||||
@@ -547,24 +587,32 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
private ItemStack pushTo( ItemStack output, ForgeDirection d )
|
||||
{
|
||||
if( output == null )
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
TileEntity te = this.getWorldObj().getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ );
|
||||
|
||||
if( te == null )
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() );
|
||||
|
||||
if( adaptor == null )
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
int size = output.stackSize;
|
||||
output = adaptor.addItems( output );
|
||||
int newSize = output == null ? 0 : output.stackSize;
|
||||
|
||||
if( size != newSize )
|
||||
{
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
this.charge -= this.ticksPerRotation;
|
||||
ICrankable g = this.getGrinder();
|
||||
if( g != null )
|
||||
{
|
||||
g.applyTurn();
|
||||
}
|
||||
}
|
||||
|
||||
this.rotation--;
|
||||
@@ -72,12 +74,16 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
public ICrankable getGrinder()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ForgeDirection grinder = this.getUp().getOpposite();
|
||||
TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ );
|
||||
if( te instanceof ICrankable )
|
||||
{
|
||||
return (ICrankable) te;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -113,7 +119,9 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
||||
public boolean power()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.rotation < 3 )
|
||||
{
|
||||
|
||||
@@ -69,7 +69,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
if( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return slotIndex >= 0 && slotIndex <= 2;
|
||||
}
|
||||
@@ -90,7 +92,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
public boolean canTurn()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
|
||||
{
|
||||
@@ -99,7 +103,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
{
|
||||
ItemStack item = src.getStackInSlot( x );
|
||||
if( item == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( item );
|
||||
if( r != null )
|
||||
@@ -111,7 +117,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
ais.stackSize = r.getInput().stackSize;
|
||||
|
||||
if( item.stackSize <= 0 )
|
||||
{
|
||||
item = null;
|
||||
}
|
||||
|
||||
src.setInventorySlotContents( x, item );
|
||||
this.setInventorySlotContents( 6, ais );
|
||||
@@ -128,7 +136,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
public void applyTurn()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.points++;
|
||||
|
||||
@@ -137,7 +147,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
if( r != null )
|
||||
{
|
||||
if( r.getEnergyCost() > this.points )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.points = 0;
|
||||
InventoryAdaptor sia = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this, 3, 3, true ), ForgeDirection.EAST );
|
||||
@@ -146,11 +158,15 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
|
||||
float chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
|
||||
if( chance <= r.getOptionalChance() )
|
||||
{
|
||||
this.addItem( sia, r.getOptionalOutput() );
|
||||
}
|
||||
|
||||
chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f;
|
||||
if( chance <= r.getSecondOptionalChance() )
|
||||
{
|
||||
this.addItem( sia, r.getSecondOptionalOutput() );
|
||||
}
|
||||
|
||||
this.setInventorySlotContents( 6, null );
|
||||
}
|
||||
@@ -159,7 +175,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
|
||||
private void addItem( InventoryAdaptor sia, ItemStack output )
|
||||
{
|
||||
if( output == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack notAdded = sia.addItems( output );
|
||||
if( notAdded != null )
|
||||
|
||||
@@ -54,8 +54,12 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
if( this.getStackInSlot( x ) != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,7 +105,9 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
{
|
||||
NBTTagCompound c = data.getCompoundTag( name );
|
||||
if( c != null )
|
||||
{
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound target )
|
||||
@@ -113,7 +119,9 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
@@ -132,7 +140,9 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
public ItemStack getStackInSlot( int var1 )
|
||||
{
|
||||
if( this.inv[var1] == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.inv[var1].getItemStack();
|
||||
}
|
||||
@@ -151,7 +161,9 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
||||
this.inv[slot] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ns = split.splitStack( qty );
|
||||
}
|
||||
|
||||
if( this.te != null && Platform.isServer() )
|
||||
{
|
||||
|
||||
@@ -58,8 +58,12 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for( int x = 0; x < this.size; x++ )
|
||||
{
|
||||
if( this.getStackInSlot( x ) != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,7 +93,9 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
this.inv[slot] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ns = split.splitStack( qty );
|
||||
}
|
||||
|
||||
if( this.te != null && this.eventsEnabled() )
|
||||
{
|
||||
@@ -246,7 +252,9 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
{
|
||||
NBTTagCompound c = data.getCompoundTag( name );
|
||||
if( c != null )
|
||||
{
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound target )
|
||||
@@ -258,7 +266,9 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
||||
NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
this.inv[x] = ItemStack.loadItemStackFromNBT( c );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
||||
@@ -66,15 +66,21 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IInventory inv = cell.getUpgradesInventory( is );
|
||||
if( inv == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.cacheUpgrades = inv;
|
||||
}
|
||||
@@ -84,10 +90,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if( this.cell.getStackInSlot( 0 ) == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
{
|
||||
return ( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -112,10 +122,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
if( name.equals( "cell" ) )
|
||||
{
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -152,12 +166,16 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
{
|
||||
this.config.setInventorySlotContents( x, configInventory.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
{
|
||||
configInventory.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
configInventory.markDirty();
|
||||
}
|
||||
@@ -165,7 +183,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
else if( this.manager.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
{
|
||||
this.config.setInventorySlotContents( x, null );
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
@@ -178,7 +198,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
if( c != null )
|
||||
{
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
{
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
c.markDirty();
|
||||
}
|
||||
@@ -191,15 +213,21 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if( inv == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.cacheConfig = inv;
|
||||
}
|
||||
@@ -212,7 +240,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
if( this.cell.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
drops.add( this.cell.getStackInSlot( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
{
|
||||
AEItemStack is = AEItemStack.create( this.getStackInSlot( 0 ) );
|
||||
if( is != null )
|
||||
{
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
@@ -113,7 +115,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
|
||||
this.tickTickTimer++;
|
||||
if( this.tickTickTimer < 20 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.tickTickTimer = 0;
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
@@ -133,7 +137,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
if( myItem == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
@@ -147,7 +153,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
this.internalCurrentPower += adjustment;
|
||||
if( oldPower > this.internalCurrentPower )
|
||||
{
|
||||
this.requiresUpdate = true;
|
||||
}
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
}
|
||||
@@ -246,7 +254,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
{
|
||||
IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem );
|
||||
@@ -261,7 +271,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
public void activate( EntityPlayer player )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
if( myItem == null )
|
||||
|
||||
@@ -83,7 +83,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
IStorageComponent sc = (IStorageComponent) is.getItem();
|
||||
if( sc.isStorageComponent( is ) )
|
||||
{
|
||||
return sc.getBytes( is ) * 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -104,7 +106,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
this.addOutput( output );
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +127,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
if( outputStack == null )
|
||||
{
|
||||
this.setInventorySlotContents( 1, output.copy() );
|
||||
}
|
||||
else
|
||||
{
|
||||
outputStack.stackSize++;
|
||||
@@ -172,7 +178,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
if( i == 0 )
|
||||
{
|
||||
if( itemstack != null )
|
||||
{
|
||||
this.addPower( itemstack.stackSize );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -222,7 +230,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
|
||||
{
|
||||
if( doFill )
|
||||
{
|
||||
this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / 500.0 );
|
||||
}
|
||||
|
||||
return resource == null ? 0 : resource.amount;
|
||||
}
|
||||
|
||||
@@ -149,9 +149,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
{
|
||||
this.inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setInventorySlotContents( num, null );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -165,7 +169,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if( this.inv.getStackInSlot( num ) != null )
|
||||
{
|
||||
slot |= ( 1 << num );
|
||||
}
|
||||
}
|
||||
|
||||
data.writeByte( slot );
|
||||
@@ -196,7 +202,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if( is != null )
|
||||
{
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +230,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if( this.smash )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i == 0 || i == 1 )
|
||||
{
|
||||
@@ -232,8 +242,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
}
|
||||
|
||||
for( ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( optionals, itemstack ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return i == 2;
|
||||
@@ -247,10 +261,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
if( mc != InvOperation.markDirty )
|
||||
{
|
||||
if( slot != 3 )
|
||||
{
|
||||
this.processingTime = 0;
|
||||
}
|
||||
|
||||
if( !this.smash )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
@@ -265,7 +283,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if( this.smash )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return slotIndex == 0 || slotIndex == 1 || slotIndex == 3;
|
||||
}
|
||||
@@ -274,10 +294,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection d )
|
||||
{
|
||||
if( d == ForgeDirection.UP )
|
||||
{
|
||||
return this.top;
|
||||
}
|
||||
|
||||
if( d == ForgeDirection.DOWN )
|
||||
{
|
||||
return this.bottom;
|
||||
}
|
||||
|
||||
return this.sides;
|
||||
}
|
||||
@@ -291,7 +315,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
private boolean hasWork()
|
||||
{
|
||||
if( this.getTask() != null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
this.processingTime = 0;
|
||||
return this.smash;
|
||||
@@ -305,13 +331,19 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
ItemStack renamedItem = this.getStackInSlot( 2 );
|
||||
|
||||
if( plateA != null && plateA.stackSize > 1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( plateB != null && plateB.stackSize > 1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( renamedItem != null && renamedItem.stackSize > 1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
boolean isNameA = namePress.isSameAs( plateA );
|
||||
@@ -333,7 +365,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( plateB );
|
||||
if( name.length() > 0 )
|
||||
{
|
||||
name += " ";
|
||||
}
|
||||
name += tag.getString( "InscribeName" );
|
||||
}
|
||||
|
||||
@@ -345,9 +379,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
tag.setTag( "display", display );
|
||||
|
||||
if( name.length() > 0 )
|
||||
{
|
||||
display.setString( "Name", name );
|
||||
}
|
||||
else
|
||||
{
|
||||
display.removeTag( "Name" );
|
||||
}
|
||||
|
||||
final List<ItemStack> inputs = Lists.newArrayList( startingItem );
|
||||
final InscriberProcessType type = InscriberProcessType.Inscribe;
|
||||
@@ -370,7 +408,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
for( ItemStack option : recipe.getInputs() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -437,9 +477,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
if( this.processingTime == 0 )
|
||||
{
|
||||
this.processingTime += speedFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.processingTime += TicksSinceLastCall * speedFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
@@ -478,10 +522,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if( name.equals( "inv" ) )
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
if( name.equals( "upgrades" ) )
|
||||
{
|
||||
return this.upgrades;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -85,21 +85,35 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
public void setSide( ForgeDirection axis )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.pointAt == axis.getOpposite() )
|
||||
{
|
||||
this.pointAt = axis;
|
||||
}
|
||||
else if( this.pointAt == axis || this.pointAt == axis.getOpposite() )
|
||||
{
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
else if( this.pointAt == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
this.pointAt = axis.getOpposite();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pointAt = Platform.rotateAround( this.pointAt, axis );
|
||||
}
|
||||
|
||||
if( ForgeDirection.UNKNOWN == this.pointAt )
|
||||
{
|
||||
this.setOrientation( this.pointAt, this.pointAt );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setOrientation( this.pointAt.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP, this.pointAt.getOpposite() );
|
||||
}
|
||||
|
||||
this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.pointAt ) ) );
|
||||
this.markForUpdate();
|
||||
@@ -145,9 +159,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if( val >= 0 && val < ForgeDirection.values().length )
|
||||
{
|
||||
this.pointAt = ForgeDirection.values()[val];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
@@ -228,7 +246,9 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||
}
|
||||
return EnumSet.of( this.pointAt );
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@ public class TilePaint extends AEBaseTile
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
{
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
}
|
||||
|
||||
void writeBuffer( ByteBuf out )
|
||||
@@ -72,14 +74,18 @@ public class TilePaint extends AEBaseTile
|
||||
out.writeByte( this.dots.size() );
|
||||
|
||||
for( Splotch s : this.dots )
|
||||
{
|
||||
s.writeToStream( out );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TilePaint( NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( "dots" ) )
|
||||
{
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
void readBuffer( ByteBuf in )
|
||||
@@ -95,7 +101,9 @@ public class TilePaint extends AEBaseTile
|
||||
|
||||
this.dots = new ArrayList( howMany );
|
||||
for( int x = 0; x < howMany; x++ )
|
||||
{
|
||||
this.dots.add( new Splotch( in ) );
|
||||
}
|
||||
|
||||
this.isLit = 0;
|
||||
for( Splotch s : this.dots )
|
||||
@@ -112,10 +120,14 @@ public class TilePaint extends AEBaseTile
|
||||
private void maxLit()
|
||||
{
|
||||
if( this.isLit > 14 )
|
||||
{
|
||||
this.isLit = 14;
|
||||
}
|
||||
|
||||
if( this.worldObj != null )
|
||||
{
|
||||
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
@@ -134,12 +146,16 @@ public class TilePaint extends AEBaseTile
|
||||
public void onNeighborBlockChange()
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
if( !this.isSideValid( side ) )
|
||||
{
|
||||
this.removeSide( side );
|
||||
}
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
@@ -158,7 +174,9 @@ public class TilePaint extends AEBaseTile
|
||||
{
|
||||
Splotch s = i.next();
|
||||
if( s.side == side )
|
||||
{
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
@@ -179,16 +197,22 @@ public class TilePaint extends AEBaseTile
|
||||
this.maxLit();
|
||||
|
||||
if( this.dots.isEmpty() )
|
||||
{
|
||||
this.dots = null;
|
||||
}
|
||||
|
||||
if( this.dots == null )
|
||||
{
|
||||
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanSide( ForgeDirection side )
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.removeSide( side );
|
||||
|
||||
@@ -211,14 +235,20 @@ public class TilePaint extends AEBaseTile
|
||||
boolean lit = ipb.isLumen( type );
|
||||
|
||||
if( this.dots == null )
|
||||
{
|
||||
this.dots = new ArrayList<Splotch>();
|
||||
}
|
||||
|
||||
if( this.dots.size() > 20 )
|
||||
{
|
||||
this.dots.remove( 0 );
|
||||
}
|
||||
|
||||
this.dots.add( new Splotch( col, lit, side, hitVec ) );
|
||||
if( lit )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
this.markForUpdate();
|
||||
@@ -229,7 +259,9 @@ public class TilePaint extends AEBaseTile
|
||||
public Collection<Splotch> getDots()
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return this.dots;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if( difference > 10 )
|
||||
{
|
||||
difference = 0;
|
||||
}
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
@@ -115,10 +117,14 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
if( !this.configSlot.isEmpty() )
|
||||
{
|
||||
drops.add( this.configSlot.getStackInSlot( 0 ) );
|
||||
}
|
||||
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
{
|
||||
drops.add( ais.getItemStack() );
|
||||
}
|
||||
}
|
||||
|
||||
IMEInventoryHandler<IAEItemStack> getSecurityInventory()
|
||||
@@ -173,7 +179,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
{
|
||||
this.cm.readFromNBT( data );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
this.securityKey = data.getLong( "securityKey" );
|
||||
this.configSlot.readFromNBT( data, "config" );
|
||||
@@ -342,7 +350,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.markDirty();
|
||||
|
||||
@@ -157,7 +157,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if( newBurnTime > 0 && is.stackSize > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -172,7 +174,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
if( this.burnTime <= 0 )
|
||||
{
|
||||
this.eatFuel();
|
||||
}
|
||||
|
||||
return new TickingRequest( TickRates.VibrationChamber.min, TickRates.VibrationChamber.max, this.burnTime <= 0, false );
|
||||
}
|
||||
@@ -185,7 +189,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
this.eatFuel();
|
||||
|
||||
if( this.burnTime > 0 )
|
||||
{
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
this.burnSpeed = 100;
|
||||
return TickRateModulation.SLEEP;
|
||||
@@ -212,9 +218,13 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE );
|
||||
|
||||
if( overFlow > 0 )
|
||||
{
|
||||
this.burnSpeed -= TicksSinceLastCall;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.burnSpeed += TicksSinceLastCall;
|
||||
}
|
||||
|
||||
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) );
|
||||
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
|
||||
@@ -243,12 +253,16 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
ItemStack container = null;
|
||||
|
||||
if( is.getItem().hasContainerItem( is ) )
|
||||
{
|
||||
container = is.getItem().getContainerItem( is );
|
||||
}
|
||||
|
||||
this.setInventorySlotContents( 0, container );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setInventorySlotContents( 0, is );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
public void markForUpdate()
|
||||
{
|
||||
if( this.worldObj == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int newLV = this.cb.getLightValue();
|
||||
if( newLV != this.oldLV )
|
||||
@@ -217,10 +219,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
if( this.cb.isEmpty() )
|
||||
{
|
||||
if( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this )
|
||||
{
|
||||
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cb.addToWorld();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,7 +336,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
{
|
||||
IImmibisMicroblocks imb = (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks );
|
||||
if( imb != null && imb.leaveParts( this ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.getWorldObj().setBlock( this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
|
||||
@@ -338,14 +346,18 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
|
||||
{
|
||||
for( AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ) )
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,9 +85,13 @@ public class TileController extends AENetworkPowerTile
|
||||
if( oldValid != this.isValid || force )
|
||||
{
|
||||
if( this.isValid )
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.updateMeta();
|
||||
@@ -96,7 +100,9 @@ public class TileController extends AENetworkPowerTile
|
||||
private void updateMeta()
|
||||
{
|
||||
if( !this.gridProxy.isReady() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int meta = 0;
|
||||
|
||||
@@ -107,7 +113,9 @@ public class TileController extends AENetworkPowerTile
|
||||
meta = 1;
|
||||
|
||||
if( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
|
||||
{
|
||||
meta = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
@@ -139,7 +147,9 @@ public class TileController extends AENetworkPowerTile
|
||||
{
|
||||
double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
|
||||
@@ -89,7 +89,9 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
IEnergyGrid grid = this.gridProxy.getEnergy();
|
||||
double leftOver = grid.injectPower( newPower, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return leftOver;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
|
||||
@@ -66,14 +66,20 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
private void changePowerLevel()
|
||||
{
|
||||
if( this.notLoaded() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.internalMaxPower ) );
|
||||
|
||||
if( boundMetadata > 7 )
|
||||
{
|
||||
boundMetadata = 7;
|
||||
}
|
||||
if( boundMetadata < 0 )
|
||||
{
|
||||
boundMetadata = 0;
|
||||
}
|
||||
|
||||
if( this.currentMeta != boundMetadata )
|
||||
{
|
||||
@@ -86,7 +92,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
public void writeToNBT_TileEnergyCell( NBTTagCompound data )
|
||||
{
|
||||
if( !this.worldObj.isRemote )
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
@@ -138,7 +146,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
{
|
||||
this.gridProxy.getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
|
||||
}
|
||||
|
||||
this.internalCurrentPower += amt;
|
||||
if( this.internalCurrentPower > this.internalMaxPower )
|
||||
@@ -189,7 +199,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if( this.internalCurrentPower > amt )
|
||||
{
|
||||
return amt;
|
||||
}
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,10 +100,14 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
try
|
||||
{
|
||||
if( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
this.clientFlags |= POWERED_FLAG;
|
||||
}
|
||||
|
||||
if( this.gridProxy.getNode().meetsChannelRequirements() )
|
||||
{
|
||||
this.clientFlags |= CHANNEL_FLAG;
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
@@ -183,7 +187,9 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
public boolean isActive()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
|
||||
}
|
||||
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@@ -95,21 +95,27 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
public final double injectAEPower( double amt, Actionable mode )
|
||||
{
|
||||
if( amt < 0.000001 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
double fakeBattery = this.internalCurrentPower + amt;
|
||||
|
||||
if( fakeBattery > this.internalMaxPower )
|
||||
{
|
||||
return fakeBattery - this.internalMaxPower;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
{
|
||||
this.PowerEvent( PowerEventType.PROVIDE_POWER );
|
||||
}
|
||||
|
||||
this.internalCurrentPower += amt;
|
||||
if( this.internalCurrentPower > this.internalMaxPower )
|
||||
@@ -163,7 +169,9 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if( this.internalCurrentPower > amt )
|
||||
{
|
||||
return amt;
|
||||
}
|
||||
return this.internalCurrentPower;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcc
|
||||
{
|
||||
double demand = this.getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE );
|
||||
if( amount > demand )
|
||||
{
|
||||
amount = demand;
|
||||
}
|
||||
|
||||
double overflow = this.injectExternalPower( PowerUnits.MK, amount );
|
||||
return amount - overflow;
|
||||
|
||||
@@ -45,7 +45,9 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
public void Tick_RotaryCraft()
|
||||
{
|
||||
if( this.worldObj != null && !this.worldObj.isRemote && this.power > 0 )
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.WA, this.power );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +90,9 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
public final void setPower( long p )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.power = p;
|
||||
}
|
||||
@@ -118,17 +122,29 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
||||
ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
|
||||
if( x == this.xCoord - 1 )
|
||||
{
|
||||
side = ForgeDirection.WEST;
|
||||
}
|
||||
else if( x == this.xCoord + 1 )
|
||||
{
|
||||
side = ForgeDirection.EAST;
|
||||
}
|
||||
else if( z == this.zCoord - 1 )
|
||||
{
|
||||
side = ForgeDirection.NORTH;
|
||||
}
|
||||
else if( z == this.zCoord + 1 )
|
||||
{
|
||||
side = ForgeDirection.SOUTH;
|
||||
}
|
||||
else if( y == this.yCoord - 1 )
|
||||
{
|
||||
side = ForgeDirection.DOWN;
|
||||
}
|
||||
else if( y == this.yCoord + 1 )
|
||||
{
|
||||
side = ForgeDirection.UP;
|
||||
}
|
||||
|
||||
return this.getPowerSides().contains( side );
|
||||
}
|
||||
|
||||
@@ -83,7 +83,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
this.updateStatus = false;
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.updateStatus( true );
|
||||
}
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
@@ -94,10 +96,14 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
int out = this.constructed;
|
||||
|
||||
if( this.getStackInSlot( 0 ) != null && this.constructed != -1 )
|
||||
{
|
||||
out |= this.hasSingularity;
|
||||
}
|
||||
|
||||
if( this.gridProxy.isActive() && this.constructed != -1 )
|
||||
{
|
||||
out |= this.powered;
|
||||
}
|
||||
|
||||
data.writeByte( (byte) out );
|
||||
}
|
||||
@@ -121,14 +127,18 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.updateStatus( true );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
if( this.isCenter() )
|
||||
{
|
||||
return this.sidesLink;
|
||||
}
|
||||
return this.sidesRing;
|
||||
}
|
||||
|
||||
@@ -187,7 +197,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
if( this.cluster != null )
|
||||
{
|
||||
if( !affectWorld )
|
||||
{
|
||||
this.cluster.updateStatus = false;
|
||||
}
|
||||
|
||||
this.cluster.destroy();
|
||||
}
|
||||
@@ -195,7 +207,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
this.cluster = null;
|
||||
|
||||
if( affectWorld )
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,7 +241,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
this.gridProxy.setValidSides( this.getConnections() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +260,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
TileEntity te = this.worldObj.getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ );
|
||||
if( te instanceof TileQuantumBridge )
|
||||
{
|
||||
set.add( d );
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
@@ -257,7 +275,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if( c != null )
|
||||
{
|
||||
return c.getLong( "freq" );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -265,7 +285,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.constructed & this.powered ) == this.powered && this.constructed != -1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -304,13 +326,17 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
public boolean hasQES()
|
||||
{
|
||||
if( this.constructed == -1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ( this.constructed & this.hasSingularity ) == this.hasSingularity;
|
||||
}
|
||||
|
||||
public void breakCluster()
|
||||
{
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,13 +71,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
public void readFromNBT_TileSpatialIOPort( NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRedstoneState()
|
||||
{
|
||||
if( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
{
|
||||
this.updateRedstoneState();
|
||||
}
|
||||
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
@@ -89,7 +93,9 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
{
|
||||
this.lastRedstoneState = currentState;
|
||||
if( this.lastRedstoneState == YesNo.YES )
|
||||
{
|
||||
this.triggerTransition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,11 +136,17 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
if( this.cluster != null )
|
||||
{
|
||||
if( this.cluster.min.equals( this.getLocation() ) )
|
||||
{
|
||||
this.displayBits = this.DISPLAY_END_MIN;
|
||||
}
|
||||
else if( this.cluster.max.equals( this.getLocation() ) )
|
||||
{
|
||||
this.displayBits = this.DISPLAY_END_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.displayBits = this.DISPLAY_MIDDLE;
|
||||
}
|
||||
|
||||
switch( this.cluster.currentAxis )
|
||||
{
|
||||
@@ -161,10 +167,14 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
try
|
||||
{
|
||||
if( this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
this.displayBits |= this.DISPLAY_POWERED_ENABLED;
|
||||
}
|
||||
|
||||
if( this.cluster.isValid && this.gridProxy.isActive() )
|
||||
{
|
||||
this.displayBits |= this.DISPLAY_ENABLED;
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
@@ -173,7 +183,9 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
}
|
||||
|
||||
if( oldBits != this.displayBits )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user