Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -36,27 +37,28 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileCraftingMonitorTile extends TileCraftingTile implements IColorableTile
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public Integer dspList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean updateList;
|
||||
|
||||
IAEItemStack dspPlay;
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCraftingMonitorTile( ByteBuf data ) throws IOException
|
||||
{
|
||||
AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
boolean hasItem = data.readBoolean();
|
||||
|
||||
if ( hasItem )
|
||||
if( hasItem )
|
||||
this.dspPlay = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
this.dspPlay = null;
|
||||
@@ -65,12 +67,12 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
return oldPaintedColor != this.paintedColor; // tesr!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCraftingMonitorTile( ByteBuf data ) throws IOException
|
||||
{
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
if ( this.dspPlay == null )
|
||||
if( this.dspPlay == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
@@ -79,15 +81,15 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingMonitorTile( NBTTagCompound data )
|
||||
{
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingMonitorTile( NBTTagCompound data )
|
||||
{
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
}
|
||||
@@ -104,16 +106,16 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setJob(IAEItemStack is)
|
||||
public void setJob( IAEItemStack is )
|
||||
{
|
||||
if ( (is == null) != (this.dspPlay == null) )
|
||||
if( ( is == null ) != ( this.dspPlay == null ) )
|
||||
{
|
||||
this.dspPlay = is == null ? null : is.copy();
|
||||
this.markForUpdate();
|
||||
}
|
||||
else if ( is != null && this.dspPlay != null )
|
||||
else if( is != null && this.dspPlay != null )
|
||||
{
|
||||
if ( is.getStackSize() != this.dspPlay.getStackSize() )
|
||||
if( is.getStackSize() != this.dspPlay.getStackSize() )
|
||||
{
|
||||
this.dspPlay = is.copy();
|
||||
this.markForUpdate();
|
||||
@@ -139,9 +141,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if ( this.paintedColor == newPaintedColor )
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -29,27 +30,27 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
||||
public static final int KILO_SCALAR = 1024;
|
||||
|
||||
@Override
|
||||
protected ItemStack getItemFromTile(Object obj)
|
||||
protected ItemStack getItemFromTile( Object obj )
|
||||
{
|
||||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final int storage = ((TileCraftingTile) obj).getStorageBytes() / KILO_SCALAR;
|
||||
final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR;
|
||||
|
||||
switch ( storage )
|
||||
switch( storage )
|
||||
{
|
||||
case 4:
|
||||
for ( ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for ( ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
break;
|
||||
case 64:
|
||||
for ( ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
@@ -74,20 +75,20 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
||||
@Override
|
||||
public int getStorageBytes()
|
||||
{
|
||||
if ( this.worldObj == null || this.notLoaded() )
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
return 0;
|
||||
|
||||
switch (this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3)
|
||||
switch( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return 1024;
|
||||
case 1:
|
||||
return 4 * 1024;
|
||||
case 2:
|
||||
return 16 * 1024;
|
||||
case 3:
|
||||
return 64 * 1024;
|
||||
default:
|
||||
case 0:
|
||||
return 1024;
|
||||
case 1:
|
||||
return 4 * 1024;
|
||||
case 2:
|
||||
return 16 * 1024;
|
||||
case 3:
|
||||
return 64 * 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
@Override
|
||||
protected ItemStack getItemFromTile( Object obj )
|
||||
{
|
||||
if ( ( (TileCraftingTile) obj ).isAccelerator() )
|
||||
if( ( (TileCraftingTile) obj ).isAccelerator() )
|
||||
{
|
||||
for ( ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return accelerator;
|
||||
}
|
||||
@@ -100,13 +100,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void setName( String name )
|
||||
{
|
||||
super.setName( name );
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.updateName();
|
||||
}
|
||||
|
||||
public boolean isAccelerator()
|
||||
{
|
||||
if ( this.worldObj == null )
|
||||
if( this.worldObj == null )
|
||||
return false;
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) == 1;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void updateStatus( CraftingCPUCluster c )
|
||||
{
|
||||
if ( this.cluster != null && this.cluster != c )
|
||||
if( this.cluster != null && this.cluster != c )
|
||||
this.cluster.breakCluster();
|
||||
|
||||
this.cluster = c;
|
||||
@@ -135,24 +135,24 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void updateMeta( boolean updateFormed )
|
||||
{
|
||||
if ( this.worldObj == null || this.notLoaded() )
|
||||
if( this.worldObj == null || this.notLoaded() )
|
||||
return;
|
||||
|
||||
boolean formed = this.isFormed();
|
||||
boolean power = false;
|
||||
|
||||
if ( this.gridProxy.isReady() )
|
||||
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 )
|
||||
if( current != newMeta )
|
||||
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, newMeta, 2 );
|
||||
|
||||
if ( updateFormed )
|
||||
if( updateFormed )
|
||||
{
|
||||
if ( formed )
|
||||
if( formed )
|
||||
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||
else
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
@@ -161,7 +161,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public boolean isFormed()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8 ) == 8;
|
||||
return this.cluster != null;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void writeToNBT_TileCraftingTile( NBTTagCompound data )
|
||||
{
|
||||
data.setBoolean( "core", this.isCoreBlock );
|
||||
if ( this.isCoreBlock && this.cluster != null )
|
||||
if( this.isCoreBlock && this.cluster != null )
|
||||
this.cluster.writeToNBT( data );
|
||||
}
|
||||
|
||||
@@ -178,9 +178,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public void readFromNBT_TileCraftingTile( NBTTagCompound data )
|
||||
{
|
||||
this.isCoreBlock = data.getBoolean( "core" );
|
||||
if ( this.isCoreBlock )
|
||||
if( this.isCoreBlock )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
this.cluster.readFromNBT( data );
|
||||
else
|
||||
this.previousState = (NBTTagCompound) data.copy();
|
||||
@@ -190,10 +190,10 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
@Override
|
||||
public void disconnect( boolean update )
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.destroy();
|
||||
if ( update )
|
||||
if( update )
|
||||
this.updateMeta( true );
|
||||
}
|
||||
}
|
||||
@@ -225,12 +225,6 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
public boolean isStatus()
|
||||
{
|
||||
return false;
|
||||
} @Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4;
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
public boolean isStorage()
|
||||
@@ -245,7 +239,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
public void breakCluster()
|
||||
{
|
||||
if ( this.cluster != null )
|
||||
if( this.cluster != null )
|
||||
{
|
||||
this.cluster.cancel();
|
||||
IMEInventory<IAEItemStack> inv = this.cluster.getInventory();
|
||||
@@ -253,20 +247,20 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
LinkedList<WorldCoord> places = new LinkedList<WorldCoord>();
|
||||
|
||||
Iterator<IGridHost> i = this.cluster.getTiles();
|
||||
while ( i.hasNext() )
|
||||
while( i.hasNext() )
|
||||
{
|
||||
IGridHost h = i.next();
|
||||
if ( h == this )
|
||||
if( h == this )
|
||||
places.add( new WorldCoord( this ) );
|
||||
else
|
||||
{
|
||||
TileEntity te = (TileEntity) h;
|
||||
|
||||
for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
WorldCoord wc = new WorldCoord( te );
|
||||
wc.add( d, 1 );
|
||||
if ( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
|
||||
if( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
|
||||
places.add( wc );
|
||||
}
|
||||
}
|
||||
@@ -274,17 +268,17 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
|
||||
Collections.shuffle( places );
|
||||
|
||||
if ( places.isEmpty() )
|
||||
if( places.isEmpty() )
|
||||
throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" );
|
||||
|
||||
for ( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
|
||||
while ( true )
|
||||
while( true )
|
||||
{
|
||||
IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() );
|
||||
if ( g == null )
|
||||
if( g == null )
|
||||
break;
|
||||
|
||||
WorldCoord wc = places.poll();
|
||||
@@ -298,12 +292,18 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4;
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
return this.gridProxy.isActive();
|
||||
return this.isPowered() && this.isFormed();
|
||||
}
|
||||
|
||||
@@ -77,8 +77,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileMolecularAssembler extends AENetworkInvTile
|
||||
implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState
|
||||
public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState
|
||||
{
|
||||
private static final int[] SIDES = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
@@ -116,19 +115,19 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where )
|
||||
{
|
||||
if ( this.myPattern == null )
|
||||
if( this.myPattern == null )
|
||||
{
|
||||
boolean isEmpty = true;
|
||||
for ( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.inv.getSizeInventory(); x++ )
|
||||
isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty;
|
||||
|
||||
if ( isEmpty && patternDetails.isCraftable() )
|
||||
if( isEmpty && patternDetails.isCraftable() )
|
||||
{
|
||||
this.forcePlan = true;
|
||||
this.myPlan = patternDetails;
|
||||
this.pushDirection = where;
|
||||
|
||||
for ( int x = 0; x < table.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < table.getSizeInventory(); x++ )
|
||||
this.inv.setInventorySlotContents( x, table.getStackInSlot( x ) );
|
||||
|
||||
this.updateSleepiness();
|
||||
@@ -143,16 +142,16 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
boolean wasEnabled = this.isAwake;
|
||||
this.isAwake = this.myPlan != null && this.hasMats() || this.canPush();
|
||||
if ( wasEnabled != this.isAwake )
|
||||
if( wasEnabled != this.isAwake )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( this.isAwake )
|
||||
if( this.isAwake )
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
else
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -166,10 +165,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private boolean hasMats()
|
||||
{
|
||||
if ( this.myPlan == null )
|
||||
if( this.myPlan == null )
|
||||
return false;
|
||||
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
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;
|
||||
@@ -204,10 +203,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileMolecularAssembler( NBTTagCompound data )
|
||||
{
|
||||
if ( this.forcePlan && this.myPlan != null )
|
||||
if( this.forcePlan && this.myPlan != null )
|
||||
{
|
||||
ItemStack pattern = this.myPlan.getPattern();
|
||||
if ( pattern != null )
|
||||
if( pattern != null )
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
pattern.writeToNBT( compound );
|
||||
@@ -224,16 +223,16 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileMolecularAssembler( NBTTagCompound data )
|
||||
{
|
||||
if ( data.hasKey( "myPlan" ) )
|
||||
if( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) );
|
||||
|
||||
if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
if( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
World w = this.getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w );
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
if( ph != null && ph.isCraftable() )
|
||||
{
|
||||
this.forcePlan = true;
|
||||
this.myPlan = ph;
|
||||
@@ -252,20 +251,20 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
this.reboot = true;
|
||||
|
||||
if ( this.forcePlan )
|
||||
if( this.forcePlan )
|
||||
return;
|
||||
|
||||
ItemStack is = this.inv.getStackInSlot( 10 );
|
||||
|
||||
if ( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
if( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
if ( !Platform.isSameItem( is, this.myPattern ) )
|
||||
if( !Platform.isSameItem( is, this.myPattern ) )
|
||||
{
|
||||
World w = this.getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
|
||||
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
if( ph != null && ph.isCraftable() )
|
||||
{
|
||||
this.progress = 0;
|
||||
this.myPattern = is;
|
||||
@@ -306,10 +305,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
if ( name.equals( "mac" ) )
|
||||
if( name.equals( "mac" ) )
|
||||
return this.inv;
|
||||
|
||||
return null;
|
||||
@@ -321,6 +320,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -330,10 +335,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( i >= 9 )
|
||||
if( i >= 9 )
|
||||
return false;
|
||||
|
||||
if ( this.hasPattern() )
|
||||
if( this.hasPattern() )
|
||||
return this.myPlan.isValidItemForSlot( i, itemstack, this.getWorldObj() );
|
||||
|
||||
return false;
|
||||
@@ -344,25 +349,19 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
return this.myPlan != null && this.inv.getStackInSlot( 10 ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( inv == this.inv )
|
||||
if( inv == this.inv )
|
||||
this.recalculatePlan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection whichSide )
|
||||
{
|
||||
@@ -379,10 +378,10 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
@@ -398,12 +397,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.inv.getStackInSlot( 9 ) != null )
|
||||
if( this.inv.getStackInSlot( 9 ) != null )
|
||||
{
|
||||
this.pushOut( this.inv.getStackInSlot( 9 ) );
|
||||
|
||||
// did it eject?
|
||||
if ( this.inv.getStackInSlot( 9 ) == null )
|
||||
if( this.inv.getStackInSlot( 9 ) == null )
|
||||
this.markDirty();
|
||||
|
||||
this.ejectHeldItems();
|
||||
@@ -412,21 +411,21 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
return this.isAwake ? TickRateModulation.IDLE : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
if ( this.myPlan == null )
|
||||
if( this.myPlan == null )
|
||||
{
|
||||
this.updateSleepiness();
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
if ( this.reboot )
|
||||
if( this.reboot )
|
||||
TicksSinceLastCall = 1;
|
||||
|
||||
if ( !this.isAwake )
|
||||
if( !this.isAwake )
|
||||
return TickRateModulation.SLEEP;
|
||||
|
||||
this.reboot = false;
|
||||
int speed = 10;
|
||||
switch ( this.upgrades.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.upgrades.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
case 0:
|
||||
this.progress += this.userPower( TicksSinceLastCall, speed = 10, 1.0 );
|
||||
@@ -448,23 +447,23 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
break;
|
||||
}
|
||||
|
||||
if ( this.progress >= 100 )
|
||||
if( this.progress >= 100 )
|
||||
{
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
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() );
|
||||
if ( output != null )
|
||||
if( output != null )
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorldObj() ), output, this.craftingInv );
|
||||
|
||||
this.pushOut( output.copy() );
|
||||
|
||||
for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
|
||||
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 )
|
||||
if( this.inv.getStackInSlot( 10 ) == null )
|
||||
{
|
||||
this.forcePlan = false;
|
||||
this.myPlan = null;
|
||||
@@ -479,7 +478,7 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
IAEItemStack item = AEItemStack.create( output );
|
||||
NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( this.xCoord, this.yCoord, this.zCoord, (byte) speed, item ), where );
|
||||
}
|
||||
catch ( IOException e )
|
||||
catch( IOException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
@@ -495,14 +494,14 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private void ejectHeldItems()
|
||||
{
|
||||
if ( this.inv.getStackInSlot( 9 ) == null )
|
||||
if( this.inv.getStackInSlot( 9 ) == null )
|
||||
{
|
||||
for ( int x = 0; x < 9; x++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ItemStack is = this.inv.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
if ( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.worldObj ) )
|
||||
if( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.worldObj ) )
|
||||
{
|
||||
this.inv.setInventorySlotContents( 9, is );
|
||||
this.inv.setInventorySlotContents( x, null );
|
||||
@@ -520,7 +519,7 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
return (int) ( this.gridProxy.getEnergy().extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -528,15 +527,15 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private void pushOut( ItemStack output )
|
||||
{
|
||||
if ( this.pushDirection == ForgeDirection.UNKNOWN )
|
||||
if( this.pushDirection == ForgeDirection.UNKNOWN )
|
||||
{
|
||||
for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
||||
output = this.pushTo( output, d );
|
||||
}
|
||||
else
|
||||
output = this.pushTo( output, this.pushDirection );
|
||||
|
||||
if ( output == null && this.forcePlan )
|
||||
if( output == null && this.forcePlan )
|
||||
{
|
||||
this.forcePlan = false;
|
||||
this.recalculatePlan();
|
||||
@@ -547,24 +546,24 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
|
||||
private ItemStack pushTo( ItemStack output, ForgeDirection d )
|
||||
{
|
||||
if ( output == null )
|
||||
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 )
|
||||
if( te == null )
|
||||
return output;
|
||||
|
||||
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() );
|
||||
|
||||
if ( adaptor == null )
|
||||
if( adaptor == null )
|
||||
return output;
|
||||
|
||||
int size = output.stackSize;
|
||||
output = adaptor.addItems( output );
|
||||
int newSize = output == null ? 0 : output.stackSize;
|
||||
|
||||
if ( size != newSize )
|
||||
if( size != newSize )
|
||||
this.markDirty();
|
||||
|
||||
return output;
|
||||
@@ -584,12 +583,12 @@ public class TileMolecularAssembler extends AENetworkInvTile
|
||||
{
|
||||
newState = this.gridProxy.isActive() && this.gridProxy.getEnergy().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.0001;
|
||||
}
|
||||
catch ( GridAccessException ignored )
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if ( newState != this.isPowered )
|
||||
if( newState != this.isPowered )
|
||||
{
|
||||
this.isPowered = newState;
|
||||
this.markForUpdate();
|
||||
|
||||
Reference in New Issue
Block a user