Basic reformat, hit once, hope never again
This commit is contained in:
@@ -25,11 +25,11 @@ public class BlockUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
for( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
final Item encodedItem = is.getItem();
|
||||
|
||||
if ( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block )
|
||||
if( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
||||
@@ -24,9 +24,9 @@ public final class DefinitionUpgradeInventory extends UpgradeInventory
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack stack : upgrades.getSupported().keySet() )
|
||||
for( ItemStack stack : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( this.definition.isSameAs( stack ) )
|
||||
if( this.definition.isSameAs( stack ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( stack );
|
||||
break;
|
||||
|
||||
@@ -18,24 +18,27 @@
|
||||
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import scala.NotImplementedError;
|
||||
|
||||
|
||||
public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
{
|
||||
|
||||
int offset = 0;
|
||||
final E[] g;
|
||||
int offset = 0;
|
||||
|
||||
public NonNullArrayIterator(E[] o) {
|
||||
public NonNullArrayIterator( E[] o )
|
||||
{
|
||||
this.g = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
while (this.offset < this.g.length && this.g[this.offset] == null)
|
||||
while( this.offset < this.g.length && this.g[this.offset] == null )
|
||||
this.offset++;
|
||||
|
||||
return this.offset != this.g.length;
|
||||
@@ -54,5 +57,4 @@ public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
{
|
||||
throw new NotImplementedError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,51 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
return this.breakBlock( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -112,22 +157,22 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
if( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
@@ -148,16 +193,6 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -166,7 +201,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
this.proxy.getTick().alertDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -175,19 +210,19 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@Override
|
||||
public void onEntityCollision( Entity entity )
|
||||
{
|
||||
if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
if( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() )
|
||||
{
|
||||
boolean capture = false;
|
||||
|
||||
switch ( this.side )
|
||||
switch( this.side )
|
||||
{
|
||||
case DOWN:
|
||||
case UP:
|
||||
if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
if( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
{
|
||||
if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
if( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
if( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -196,11 +231,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
if( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 )
|
||||
{
|
||||
if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
if( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
if( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -209,11 +244,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
case EAST:
|
||||
case WEST:
|
||||
if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
if( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 )
|
||||
{
|
||||
if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
if( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 )
|
||||
{
|
||||
if ( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
if( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) )
|
||||
{
|
||||
capture = true;
|
||||
}
|
||||
@@ -225,7 +260,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
break;
|
||||
}
|
||||
|
||||
if ( capture )
|
||||
if( capture )
|
||||
{
|
||||
ServerHelper.proxy.sendToAllNearExcept( null, this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, 64, this.tile.getWorldObj(), new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.side, false ) );
|
||||
this.storeEntityItem( (EntityItem) entity );
|
||||
@@ -233,69 +268,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if ( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if ( this.isAnnihilationPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the plane is accepting items.
|
||||
*
|
||||
* This might be improved if a performance problem shows up.
|
||||
*
|
||||
* @return true if planes accepts items.
|
||||
*/
|
||||
private boolean isAccepting()
|
||||
{
|
||||
return this.isAccepting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
|
||||
*
|
||||
@@ -303,7 +281,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
*/
|
||||
private void storeEntityItem( EntityItem entityItem )
|
||||
{
|
||||
if ( !entityItem.isDead )
|
||||
if( !entityItem.isDead )
|
||||
{
|
||||
this.storeItemStack( entityItem.getEntityItem() );
|
||||
entityItem.setDead();
|
||||
@@ -328,7 +306,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
this.isAccepting = overflow == null;
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
catch( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -336,7 +314,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
private void spawnOverflowItemStack( IAEItemStack overflow )
|
||||
{
|
||||
if ( overflow == null )
|
||||
if( overflow == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -351,6 +329,28 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) );
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the plane is accepting items.
|
||||
*
|
||||
* This might be improved if a performance problem shows up.
|
||||
*
|
||||
* @return true if planes accepts items.
|
||||
*/
|
||||
private boolean isAccepting()
|
||||
{
|
||||
return this.isAccepting;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( MENetworkChannelsChanged c )
|
||||
@@ -369,7 +369,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
|
||||
public TickRateModulation breakBlock( boolean modulate )
|
||||
{
|
||||
if ( this.isAccepting && this.proxy.isActive() )
|
||||
if( this.isAccepting && this.proxy.isActive() )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -387,16 +387,16 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final Material mat = blk.getMaterial();
|
||||
final boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock || blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block;
|
||||
|
||||
if ( !ignore && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
|
||||
if( !ignore && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
|
||||
{
|
||||
final float hardness = blk.getBlockHardness( w, x, y, z );
|
||||
|
||||
if ( hardness >= 0.0 )
|
||||
if( hardness >= 0.0 )
|
||||
{
|
||||
final ItemStack[] out = Platform.getBlockDrops( w, x, y, z );
|
||||
|
||||
float total = 1 + hardness;
|
||||
for ( final ItemStack is : out )
|
||||
for( final ItemStack is : out )
|
||||
{
|
||||
total += is.stackSize;
|
||||
}
|
||||
@@ -404,24 +404,24 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final boolean hasPower = energy.extractAEPower( total, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > total - 0.1;
|
||||
final boolean canStore = this.canStoreItemStacks( out );
|
||||
|
||||
if ( hasPower && canStore )
|
||||
if( hasPower && canStore )
|
||||
{
|
||||
if ( modulate )
|
||||
if( modulate )
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.AIR, 0, 3 );
|
||||
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
final AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 );
|
||||
for ( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
|
||||
for( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
|
||||
{
|
||||
if ( ei instanceof EntityItem )
|
||||
if( ei instanceof EntityItem )
|
||||
{
|
||||
final EntityItem entityItem = (EntityItem) ei;
|
||||
this.storeEntityItem( entityItem );
|
||||
}
|
||||
}
|
||||
|
||||
for ( final ItemStack snaggedItem : out )
|
||||
for( final ItemStack snaggedItem : out )
|
||||
{
|
||||
this.storeItemStack( snaggedItem );
|
||||
}
|
||||
@@ -438,7 +438,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( final GridAccessException e1 )
|
||||
catch( final GridAccessException e1 )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
if ( this.breaking )
|
||||
if( this.breaking )
|
||||
{
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
@@ -483,17 +483,17 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
final IStorageGrid storage = this.proxy.getStorage();
|
||||
|
||||
for ( final ItemStack itemStack : itemStacks )
|
||||
for( final ItemStack itemStack : itemStacks )
|
||||
{
|
||||
final IAEItemStack itemToTest = AEItemStack.create( itemStack );
|
||||
final IAEItemStack overflow = storage.getItemInventory().injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
|
||||
if ( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
|
||||
if( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
|
||||
{
|
||||
canStore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( final GridAccessException e )
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -82,13 +82,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
@@ -96,16 +89,23 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.cratingTracker.readFromNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.itemToSend = 1;
|
||||
this.didSomething = false;
|
||||
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
@@ -133,38 +133,38 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
ICraftingGrid cg = this.proxy.getCrafting();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( d != null )
|
||||
if( d != null )
|
||||
{
|
||||
for ( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
for( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
if ( ais == null || this.itemToSend <= 0 || this.craftOnly() )
|
||||
if( ais == null || this.itemToSend <= 0 || this.craftOnly() )
|
||||
{
|
||||
if ( this.isCraftingEnabled() )
|
||||
if( this.isCraftingEnabled() )
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
continue;
|
||||
}
|
||||
|
||||
long before = this.itemToSend;
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
for ( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
for( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, o );
|
||||
if ( this.itemToSend <= 0 )
|
||||
if( this.itemToSend <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.pushItemIntoTarget( d, energy, inv, ais );
|
||||
|
||||
if ( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -172,6 +172,15 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -213,15 +222,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -231,9 +231,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_BUS );
|
||||
@@ -244,9 +244,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,9 +256,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,18 +285,18 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
ItemStack o = d.simulateAdd( is );
|
||||
long canFit = o == null ? this.itemToSend : this.itemToSend - o.stackSize;
|
||||
|
||||
if ( canFit > 0 )
|
||||
if( canFit > 0 )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( canFit );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, this.mySrc );
|
||||
|
||||
if ( itemsToAdd != null )
|
||||
if( itemsToAdd != null )
|
||||
{
|
||||
this.itemToSend -= itemsToAdd.getStackSize();
|
||||
|
||||
ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
|
||||
if ( failed != null )
|
||||
if( failed != null )
|
||||
{
|
||||
ais.setStackSize( failed.stackSize );
|
||||
inv.injectItems( ais, Actionable.MODULATE, this.mySrc );
|
||||
@@ -320,20 +320,20 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
|
||||
try
|
||||
{
|
||||
if ( d != null && this.proxy.isActive() )
|
||||
if( d != null && this.proxy.isActive() )
|
||||
{
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
double power = items.getStackSize();
|
||||
if ( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
|
||||
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
if( mode == Actionable.MODULATE )
|
||||
return AEItemStack.create( d.addItems( items.getItemStack() ) );
|
||||
return AEItemStack.create( d.simulateAdd( items.getItemStack() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
private void updateHandler()
|
||||
{
|
||||
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
|
||||
@@ -111,14 +110,14 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for ( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
{
|
||||
IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
priorityList.add( is );
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
else
|
||||
this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) );
|
||||
@@ -127,28 +126,39 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
this.updateHandler();
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if( inv == this.Config )
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
@@ -159,48 +169,29 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.Config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.Config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.updateHandler();
|
||||
this.host.markForSave();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if ( inv == this.Config )
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( MENetworkPowerStatusChange c )
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
@@ -208,12 +199,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
boolean currentActive = this.proxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();// proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
@@ -221,6 +211,42 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
TileEntity te = host.getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -235,7 +261,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -250,16 +275,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
TileEntity te = this.getHost().getTile();
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
|
||||
boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
|
||||
@@ -278,18 +303,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
|
||||
private boolean isTransitionPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if ( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -304,58 +317,18 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
IPartHost host = this.getHost();
|
||||
if ( host != null )
|
||||
{
|
||||
TileEntity te = host.getTile();
|
||||
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
ForgeDirection e = bch.getWorldX();
|
||||
ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) )
|
||||
minX = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) )
|
||||
maxX = 16;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) )
|
||||
minY = 0;
|
||||
|
||||
if ( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) )
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE );
|
||||
@@ -365,11 +338,20 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTransitionPlane( TileEntity blockTileEntity, ForgeDirection side )
|
||||
{
|
||||
if( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( StorageChannel channel )
|
||||
{
|
||||
if ( this.proxy.isActive() && channel == StorageChannel.ITEMS )
|
||||
if( this.proxy.isActive() && channel == StorageChannel.ITEMS )
|
||||
{
|
||||
List<IMEInventoryHandler> Handler = new ArrayList<IMEInventoryHandler>( 1 );
|
||||
Handler.add( this.myHandler );
|
||||
@@ -378,14 +360,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return new ArrayList<IMEInventoryHandler>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
@@ -394,18 +374,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void blinkCell( int slot )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src )
|
||||
{
|
||||
if ( this.blocked || input == null || input.getStackSize() <= 0 )
|
||||
if( this.blocked || input == null || input.getStackSize() <= 0 )
|
||||
return input;
|
||||
|
||||
YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
|
||||
@@ -424,40 +402,40 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
int y = te.yCoord + side.offsetY;
|
||||
int z = te.zCoord + side.offsetZ;
|
||||
|
||||
if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) )
|
||||
if( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) )
|
||||
{
|
||||
if ( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) )
|
||||
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) )
|
||||
{
|
||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
||||
Platform.configurePlayer( player, side, this.tile );
|
||||
|
||||
if ( i instanceof ItemFirework )
|
||||
if( i instanceof ItemFirework )
|
||||
{
|
||||
Chunk c = w.getChunkFromBlockCoords( x, z );
|
||||
int sum = 0;
|
||||
for ( List Z : c.entityLists )
|
||||
for( List Z : c.entityLists )
|
||||
sum += Z.size();
|
||||
if ( sum > 32 )
|
||||
if( sum > 32 )
|
||||
return input;
|
||||
}
|
||||
maxStorage = is.stackSize;
|
||||
worked = true;
|
||||
if ( type == Actionable.MODULATE )
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
if ( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
|
||||
if( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
|
||||
{
|
||||
boolean Worked = false;
|
||||
|
||||
if ( side.offsetX == 0 && side.offsetZ == 0 )
|
||||
if( side.offsetX == 0 && side.offsetZ == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked && side.offsetX == 0 && side.offsetZ == 0 )
|
||||
if( !Worked && side.offsetX == 0 && side.offsetZ == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked && side.offsetY == 0 )
|
||||
if( !Worked && side.offsetY == 0 )
|
||||
Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
if ( !Worked )
|
||||
if( !Worked )
|
||||
i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
|
||||
|
||||
maxStorage -= is.stackSize;
|
||||
@@ -476,12 +454,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
worked = true;
|
||||
Chunk c = w.getChunkFromBlockCoords( x, z );
|
||||
int sum = 0;
|
||||
for ( List Z : c.entityLists )
|
||||
for( List Z : c.entityLists )
|
||||
sum += Z.size();
|
||||
|
||||
if ( sum < AEConfig.instance.formationPlaneEntityLimit )
|
||||
if( sum < AEConfig.instance.formationPlaneEntityLimit )
|
||||
{
|
||||
if ( type == Actionable.MODULATE )
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
|
||||
is.stackSize = (int) maxStorage;
|
||||
@@ -497,16 +475,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
ei.motionY = side.offsetY * 0.2;
|
||||
ei.motionZ = side.offsetZ * 0.2;
|
||||
|
||||
if ( is.getItem().hasCustomEntity( is ) )
|
||||
if( is.getItem().hasCustomEntity( is ) )
|
||||
{
|
||||
result = is.getItem().createEntity( w, ei, is );
|
||||
if ( result != null )
|
||||
if( result != null )
|
||||
ei.setDead();
|
||||
else
|
||||
result = ei;
|
||||
}
|
||||
|
||||
if ( !w.spawnEntityInWorld( result ) )
|
||||
if( !w.spawnEntityInWorld( result ) )
|
||||
{
|
||||
result.setDead();
|
||||
worked = false;
|
||||
@@ -520,11 +498,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z );
|
||||
|
||||
if ( worked )
|
||||
if( worked )
|
||||
{
|
||||
IAEItemStack out = input.copy();
|
||||
out.decStackSize( maxStorage );
|
||||
if ( out.getStackSize() == 0 )
|
||||
if( out.getStackSize() == 0 )
|
||||
return null;
|
||||
return out;
|
||||
}
|
||||
@@ -532,28 +510,24 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveChanges( IMEInventory cellInventory )
|
||||
{
|
||||
|
||||
@@ -77,15 +77,23 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
if ( stack == null || stack.getItem() == null )
|
||||
if( stack == null || stack.getItem() == null )
|
||||
return false;
|
||||
|
||||
IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source );
|
||||
if ( out == null )
|
||||
if( out == null )
|
||||
return true;
|
||||
return out.getStackSize() != stack.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -125,14 +133,6 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
@@ -142,9 +142,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_BUS );
|
||||
@@ -169,7 +169,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
{
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
this.worked = false;
|
||||
@@ -177,11 +177,11 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
InventoryAdaptor myAdaptor = this.getHandler();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if ( myAdaptor != null )
|
||||
if( myAdaptor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
switch ( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
@@ -206,30 +206,30 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
boolean Configured = false;
|
||||
for ( int x = 0; x < this.availableSlots(); x++ )
|
||||
for( int x = 0; x < this.availableSlots(); x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
if ( ais != null && this.itemToSend > 0 )
|
||||
if( ais != null && this.itemToSend > 0 )
|
||||
{
|
||||
Configured = true;
|
||||
while ( this.itemToSend > 0 )
|
||||
while( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
|
||||
if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !Configured )
|
||||
if( !Configured )
|
||||
{
|
||||
while ( this.itemToSend > 0 )
|
||||
while( this.itemToSend > 0 )
|
||||
{
|
||||
if ( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
|
||||
if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :3
|
||||
}
|
||||
@@ -244,28 +244,28 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
{
|
||||
int toSend = this.itemToSend;
|
||||
|
||||
if ( toSend > 64 )
|
||||
if( toSend > 64 )
|
||||
toSend = 64;
|
||||
|
||||
ItemStack newItems;
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) );
|
||||
else
|
||||
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), this.configDestination( inv ) );
|
||||
|
||||
if ( newItems != null )
|
||||
if( newItems != null )
|
||||
{
|
||||
newItems.stackSize = (int) ( Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 );
|
||||
this.itemToSend -= newItems.stackSize;
|
||||
|
||||
if ( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
|
||||
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
|
||||
this.lastItemChecked = AEApi.instance().storage().createItemStack( newItems );
|
||||
else
|
||||
this.lastItemChecked.setStackSize( newItems.stackSize );
|
||||
|
||||
IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source );
|
||||
// destination.injectItems( lastItemChecked, Actionable.MODULATE );
|
||||
if ( failed != null )
|
||||
if( failed != null )
|
||||
{
|
||||
myAdaptor.addItems( failed.getItemStack() );
|
||||
return true;
|
||||
@@ -285,15 +285,15 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartLevelEmitter extends PartUpgradeable
|
||||
implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
||||
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
||||
{
|
||||
|
||||
final int FLAG_ON = 4;
|
||||
@@ -120,7 +119,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
public void setReportingValue( long v )
|
||||
{
|
||||
this.reportingValue = v;
|
||||
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
this.configureWatchers();
|
||||
else
|
||||
this.updateState();
|
||||
@@ -135,7 +134,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
private void updateState()
|
||||
{
|
||||
boolean isOn = this.isLevelEmitterOn();
|
||||
if ( this.prevState != isOn )
|
||||
if( this.prevState != isOn )
|
||||
{
|
||||
this.host.markForUpdate();
|
||||
TileEntity te = this.host.getTile();
|
||||
@@ -147,23 +146,23 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
private boolean isLevelEmitterOn()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON;
|
||||
}
|
||||
|
||||
if ( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -206,41 +205,40 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
// update the system...
|
||||
public void configureWatchers()
|
||||
{
|
||||
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||
|
||||
if ( this.myWatcher != null )
|
||||
if( this.myWatcher != null )
|
||||
this.myWatcher.clear();
|
||||
|
||||
if ( this.myEnergyWatcher != null )
|
||||
if( this.myEnergyWatcher != null )
|
||||
this.myEnergyWatcher.clear();
|
||||
|
||||
if ( this.myCraftingWatcher != null )
|
||||
if( this.myCraftingWatcher != null )
|
||||
this.myCraftingWatcher.clear();
|
||||
|
||||
try
|
||||
{
|
||||
this.proxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.proxy.getNode() ) );
|
||||
}
|
||||
catch ( GridAccessException e1 )
|
||||
catch( GridAccessException e1 )
|
||||
{
|
||||
// :/
|
||||
}
|
||||
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
if ( this.myCraftingWatcher != null && myStack != null )
|
||||
if( this.myCraftingWatcher != null && myStack != null )
|
||||
this.myCraftingWatcher.add( myStack );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
||||
{
|
||||
if ( this.myEnergyWatcher != null )
|
||||
if( this.myEnergyWatcher != null )
|
||||
this.myEnergyWatcher.add( (double) this.reportingValue );
|
||||
|
||||
try
|
||||
@@ -252,7 +250,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// no more item stuff..
|
||||
this.proxy.getStorage().getItemInventory().removeListener( this );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -262,7 +260,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
try
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
||||
{
|
||||
this.proxy.getStorage().getItemInventory().addListener( this, this.proxy.getGrid() );
|
||||
}
|
||||
@@ -270,41 +268,40 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
this.proxy.getStorage().getItemInventory().removeListener( this );
|
||||
|
||||
if ( this.myWatcher != null )
|
||||
if( this.myWatcher != null )
|
||||
this.myWatcher.add( myStack );
|
||||
}
|
||||
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// >.>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateReportingValue( IMEMonitor<IAEItemStack> monitor )
|
||||
{
|
||||
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||
|
||||
if ( myStack == null )
|
||||
if( myStack == null )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
for ( IAEItemStack st : monitor.getStorageList() )
|
||||
for( IAEItemStack st : monitor.getStorageList() )
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
}
|
||||
else if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
|
||||
for ( IAEItemStack st : fuzzyList )
|
||||
for( IAEItemStack st : fuzzyList )
|
||||
this.lastReportedValue += st.getStackSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
|
||||
if ( r == null )
|
||||
if( r == null )
|
||||
this.lastReportedValue = 0;
|
||||
else
|
||||
this.lastReportedValue = r.getStackSize();
|
||||
@@ -313,7 +310,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IStackWatcher newWatcher )
|
||||
{
|
||||
@@ -321,18 +317,16 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
||||
if( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
||||
{
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IEnergyWatcher newWatcher )
|
||||
{
|
||||
@@ -340,7 +334,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onThresholdPass( IEnergyGrid energyGrid )
|
||||
{
|
||||
@@ -348,7 +341,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValid( Object effectiveGrid )
|
||||
{
|
||||
@@ -356,20 +348,18 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
return this.proxy.getGrid() == effectiveGrid;
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
|
||||
{
|
||||
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
@@ -377,12 +367,23 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
{
|
||||
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// ;P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -396,7 +397,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
|
||||
public void renderTorchAtAngle( double baseX, double baseY, double baseZ )
|
||||
{
|
||||
boolean isOn = this.isLevelEmitterOn();
|
||||
@@ -457,13 +457,13 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
|
||||
double toff = 0.0d;
|
||||
|
||||
if ( !isOn )
|
||||
if( !isOn )
|
||||
{
|
||||
toff = 1.0d / 16.0d;
|
||||
}
|
||||
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
if ( isOn )
|
||||
if( isOn )
|
||||
{
|
||||
var12.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
||||
var12.setBrightness( 11 << 20 | 11 << 4 );
|
||||
@@ -505,7 +505,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, var17, var18 );
|
||||
}
|
||||
|
||||
|
||||
public void addVertexWithUV( double x, double y, double z, double u, double v )
|
||||
{
|
||||
Tessellator var12 = Tessellator.instance;
|
||||
@@ -514,13 +513,13 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y -= this.centerY;
|
||||
z -= this.centerZ;
|
||||
|
||||
if ( this.side == ForgeDirection.DOWN )
|
||||
if( this.side == ForgeDirection.DOWN )
|
||||
{
|
||||
y = -y;
|
||||
z = -z;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.EAST )
|
||||
if( this.side == ForgeDirection.EAST )
|
||||
{
|
||||
double m = x;
|
||||
x = y;
|
||||
@@ -528,14 +527,14 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.WEST )
|
||||
if( this.side == ForgeDirection.WEST )
|
||||
{
|
||||
double m = x;
|
||||
x = -y;
|
||||
y = m;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.SOUTH )
|
||||
if( this.side == ForgeDirection.SOUTH )
|
||||
{
|
||||
double m = z;
|
||||
z = y;
|
||||
@@ -543,7 +542,7 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
y = -y;
|
||||
}
|
||||
|
||||
if ( this.side == ForgeDirection.NORTH )
|
||||
if( this.side == ForgeDirection.NORTH )
|
||||
{
|
||||
double m = z;
|
||||
z = -y;
|
||||
@@ -557,7 +556,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
var12.addVertexWithUV( x, y, z, u, v );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
||||
@@ -587,32 +585,22 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
||||
{
|
||||
if ( this.isLevelEmitterOn() )
|
||||
if( this.isLevelEmitterOn() )
|
||||
{
|
||||
ForgeDirection d = this.side;
|
||||
|
||||
@@ -624,27 +612,18 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER );
|
||||
@@ -654,6 +633,26 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if( inv == this.config )
|
||||
this.configureWatchers();
|
||||
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
@@ -661,18 +660,6 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
@@ -683,40 +670,25 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
this.config.readFromNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.config )
|
||||
this.configureWatchers();
|
||||
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
||||
{
|
||||
@@ -732,12 +704,12 @@ public class PartLevelEmitter extends PartUpgradeable
|
||||
@Override
|
||||
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||
{
|
||||
if ( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES )
|
||||
if( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES )
|
||||
{
|
||||
IAEItemStack what = this.config.getAEStackInSlot( 0 );
|
||||
if ( what != null )
|
||||
if( what != null )
|
||||
craftingTracker.setEmitable( what );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
public void upgradesChanged()
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,30 +66,31 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
this.updateState();
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !this.isSleeping() )
|
||||
if( !this.isSleeping() )
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
else
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
|
||||
int newAdaptorHash = Platform.generateTileHash( target );
|
||||
|
||||
if ( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
if( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
return this.adaptor;
|
||||
|
||||
this.adaptorHash = newAdaptorHash;
|
||||
@@ -116,7 +116,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
{
|
||||
World w = self.getWorldObj();
|
||||
|
||||
if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
if( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
@@ -128,10 +128,10 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.updateState();
|
||||
if ( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
if( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
{
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if ( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
this.doBusWork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,64 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if( inv == this.upgrades )
|
||||
{
|
||||
this.upgradesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradesChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 )
|
||||
{
|
||||
switch( this.getRSMode() )
|
||||
{
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
case HIGH_SIGNAL:
|
||||
if( this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
if( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
@@ -77,8 +135,8 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
@Override
|
||||
public void getDrops( List<ItemStack> drops, boolean wrenched )
|
||||
{
|
||||
for ( ItemStack is : this.upgrades )
|
||||
if ( is != null )
|
||||
for( ItemStack is : this.upgrades )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@@ -91,70 +149,12 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.upgrades )
|
||||
{
|
||||
this.upgradesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradesChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 )
|
||||
{
|
||||
switch ( this.getRSMode() )
|
||||
{
|
||||
case IGNORE:
|
||||
return false;
|
||||
|
||||
case HIGH_SIGNAL:
|
||||
if ( this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
if ( !this.host.hasRedstone( this.side ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case SIGNAL_PULSE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -18,14 +18,13 @@ public class StackUpgradeInventory extends UpgradeInventory
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
|
||||
public int getMaxInstalled( Upgrades upgrades )
|
||||
{
|
||||
int max = 0;
|
||||
|
||||
for ( ItemStack is : upgrades.getSupported().keySet() )
|
||||
for( ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if ( Platform.isSameItem( this.stack, is ) )
|
||||
if( Platform.isSameItem( this.stack, is ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
||||
@@ -66,13 +66,13 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( itemstack == null )
|
||||
if( itemstack == null )
|
||||
return false;
|
||||
Item it = itemstack.getItem();
|
||||
if ( it instanceof IUpgradeModule )
|
||||
if( it instanceof IUpgradeModule )
|
||||
{
|
||||
Upgrades u = ( (IUpgradeModule) it ).getType( itemstack );
|
||||
if ( u != null )
|
||||
if( u != null )
|
||||
{
|
||||
return this.getInstalledUpgrades( u ) < this.getMaxInstalled( u );
|
||||
}
|
||||
@@ -82,10 +82,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
if ( !this.cached )
|
||||
if( !this.cached )
|
||||
this.updateUpgradeInfo();
|
||||
|
||||
switch ( u )
|
||||
switch( u )
|
||||
{
|
||||
case CAPACITY:
|
||||
return this.capacityUpgrades;
|
||||
@@ -111,13 +111,13 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
this.cached = true;
|
||||
this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0;
|
||||
|
||||
for ( ItemStack is : this )
|
||||
for( ItemStack is : this )
|
||||
{
|
||||
if ( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) )
|
||||
if( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) )
|
||||
continue;
|
||||
|
||||
Upgrades myUpgrade = ( (IUpgradeModule) is.getItem() ).getType( is );
|
||||
switch ( myUpgrade )
|
||||
switch( myUpgrade )
|
||||
{
|
||||
case CAPACITY:
|
||||
this.capacityUpgrades++;
|
||||
@@ -167,7 +167,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
this.cached = false;
|
||||
if ( this.parent != null && Platform.isServer() )
|
||||
if( this.parent != null && Platform.isServer() )
|
||||
this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user