Puts everywhere brackets
This commit is contained in:
@@ -98,7 +98,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction )
|
||||
{
|
||||
if( !this.output )
|
||||
{
|
||||
return direction == this.side;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -106,7 +108,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction )
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return direction == this.side;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -114,7 +118,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -154,30 +160,42 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
}
|
||||
|
||||
if( outs.isEmpty() )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
LinkedList<PartP2PIC2Power> Options = new LinkedList<PartP2PIC2Power>();
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
if( o.OutputEnergyA <= 0.01 )
|
||||
{
|
||||
Options.add( o );
|
||||
}
|
||||
}
|
||||
|
||||
if( Options.isEmpty() )
|
||||
{
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
if( o.OutputEnergyB <= 0.01 )
|
||||
{
|
||||
Options.add( o );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( Options.isEmpty() )
|
||||
{
|
||||
for( PartP2PIC2Power o : outs )
|
||||
{
|
||||
Options.add( o );
|
||||
}
|
||||
}
|
||||
|
||||
if( Options.isEmpty() )
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
PartP2PIC2Power x = Platform.pickRandom( Options );
|
||||
|
||||
@@ -209,7 +227,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return this.OutputEnergyA;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -231,7 +251,9 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
public int getSourceTier()
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return this.calculateTierFromVoltage( this.OutputVoltageA );
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
this.cachedInv = null;
|
||||
PartP2PItems input = this.getInput();
|
||||
if( input != null && this.output )
|
||||
{
|
||||
input.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
|
||||
IInventory getDestination()
|
||||
@@ -89,7 +91,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
this.requested = true;
|
||||
|
||||
if( this.cachedInv != null )
|
||||
{
|
||||
return this.cachedInv;
|
||||
}
|
||||
|
||||
List<IInventory> outs = new LinkedList<IInventory>();
|
||||
TunnelCollection<PartP2PItems> itemTunnels;
|
||||
@@ -109,9 +113,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
if( inv != null )
|
||||
{
|
||||
if( Platform.getRandomInt() % 2 == 0 )
|
||||
{
|
||||
outs.add( inv );
|
||||
}
|
||||
else
|
||||
{
|
||||
outs.add( 0, inv );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +135,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ );
|
||||
|
||||
if( this.which.contains( this ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.which.add( this );
|
||||
|
||||
@@ -189,7 +199,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
boolean wasReq = this.requested;
|
||||
|
||||
if( this.requested && this.cachedInv != null )
|
||||
{
|
||||
( (WrapperChainedInventory) this.cachedInv ).cycleOrder();
|
||||
}
|
||||
|
||||
this.requested = false;
|
||||
return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
@@ -264,7 +276,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
{
|
||||
PartP2PItems input = this.getInput();
|
||||
if( input != null )
|
||||
{
|
||||
input.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +287,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
{
|
||||
int[] slots = new int[this.getSizeInventory()];
|
||||
for( int x = 0; x < this.getSizeInventory(); x++ )
|
||||
{
|
||||
slots[x] = x;
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,9 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
private boolean doWork()
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity te = this.getTile();
|
||||
World w = te.getWorldObj();
|
||||
@@ -100,7 +102,9 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
try
|
||||
{
|
||||
for( PartP2PLight out : this.getOutputs() )
|
||||
{
|
||||
out.setLightLevel( this.lastValue );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
@@ -119,14 +123,18 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
this.doWork();
|
||||
|
||||
if( this.output )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
if( this.output && this.isPowered() )
|
||||
{
|
||||
return this.blockLight( this.lastValue );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -160,7 +168,9 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
if( tag.hasKey( "opacity" ) )
|
||||
{
|
||||
this.opacity = tag.getFloat( "opacity" );
|
||||
}
|
||||
this.lastValue = tag.getInteger( "lastValue" );
|
||||
}
|
||||
|
||||
@@ -185,12 +195,18 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
{
|
||||
PartP2PLight src = this.getInput();
|
||||
if( src != null && src.proxy.isActive() )
|
||||
{
|
||||
this.setLightLevel( src.lastValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,7 +80,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
{
|
||||
PartP2PLiquids in = this.getInput();
|
||||
if( in != null )
|
||||
{
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +92,12 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
Stack<PartP2PLiquids> stack = this.getDepth();
|
||||
|
||||
for( PartP2PLiquids t : stack )
|
||||
{
|
||||
if( t == this )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
stack.push( this );
|
||||
|
||||
@@ -104,20 +110,30 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
PartP2PLiquids l = i.next();
|
||||
IFluidHandler tank = l.getTarget();
|
||||
if( tank != null )
|
||||
{
|
||||
l.tmpUsed = tank.fill( l.side.getOpposite(), resource.copy(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
l.tmpUsed = 0;
|
||||
}
|
||||
|
||||
if( l.tmpUsed <= 0 )
|
||||
{
|
||||
i.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
requestTotal += l.tmpUsed;
|
||||
}
|
||||
}
|
||||
|
||||
if( requestTotal <= 0 )
|
||||
{
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -125,7 +141,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
if( !doFill )
|
||||
{
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return Math.min( resource.amount, requestTotal );
|
||||
}
|
||||
@@ -141,20 +159,28 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
FluidStack insert = resource.copy();
|
||||
insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
|
||||
if( insert.amount > available )
|
||||
{
|
||||
insert.amount = available;
|
||||
}
|
||||
|
||||
IFluidHandler tank = l.getTarget();
|
||||
if( tank != null )
|
||||
{
|
||||
l.tmpUsed = tank.fill( l.side.getOpposite(), insert.copy(), true );
|
||||
}
|
||||
else
|
||||
{
|
||||
l.tmpUsed = 0;
|
||||
}
|
||||
|
||||
available -= insert.amount;
|
||||
used += insert.amount;
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
@@ -164,7 +190,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
Stack<PartP2PLiquids> s = DEPTH.get();
|
||||
|
||||
if( s == null )
|
||||
{
|
||||
DEPTH.set( s = new Stack<PartP2PLiquids>() );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -181,7 +209,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
if( handler != null )
|
||||
{
|
||||
if( handler.canFill( l.side.getOpposite(), input ) )
|
||||
{
|
||||
outs.add( l );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,14 +226,20 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
IFluidHandler getTarget()
|
||||
{
|
||||
if( !this.proxy.isActive() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if( this.cachedTank != null )
|
||||
{
|
||||
return this.cachedTank;
|
||||
}
|
||||
|
||||
TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ );
|
||||
if( te instanceof IFluidHandler )
|
||||
{
|
||||
return this.cachedTank = (IFluidHandler) te;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -236,7 +272,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
public FluidTankInfo[] getTankInfo( ForgeDirection from )
|
||||
{
|
||||
if( from == this.side )
|
||||
{
|
||||
return this.getTank();
|
||||
}
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
|
||||
@@ -246,14 +284,18 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
{
|
||||
PartP2PLiquids tun = this.getInput();
|
||||
if( tun != null )
|
||||
{
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !this.getOutputs().isEmpty() )
|
||||
{
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -81,15 +81,21 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate )
|
||||
{
|
||||
if( this.output )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( this.isActive() )
|
||||
{
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for( PartP2PRFPower t : stack )
|
||||
{
|
||||
if( t == this )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
stack.push( this );
|
||||
|
||||
@@ -106,7 +112,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
total += receiver;
|
||||
|
||||
if( maxReceive <= 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +127,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
total += receiver;
|
||||
|
||||
if( maxReceive <= 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +140,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -143,7 +155,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
Stack<PartP2PRFPower> s = THREAD_STACK.get();
|
||||
|
||||
if( s == null )
|
||||
{
|
||||
THREAD_STACK.set( s = new Stack<PartP2PRFPower>() );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
@@ -161,7 +175,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
}
|
||||
|
||||
if( this.outputTarget == null || !this.outputTarget.canConnectEnergy( this.side.getOpposite() ) )
|
||||
{
|
||||
return NULL_HANDLER;
|
||||
}
|
||||
|
||||
return this.outputTarget;
|
||||
}
|
||||
@@ -172,15 +188,21 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
public int getEnergyStored( ForgeDirection from )
|
||||
{
|
||||
if( this.output || !this.isActive() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for( PartP2PRFPower t : stack )
|
||||
{
|
||||
if( t == this )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
stack.push( this );
|
||||
|
||||
@@ -197,7 +219,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -206,15 +230,21 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
public int getMaxEnergyStored( ForgeDirection from )
|
||||
{
|
||||
if( this.output || !this.isActive() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
|
||||
Stack<PartP2PRFPower> stack = this.getDepth();
|
||||
|
||||
for( PartP2PRFPower t : stack )
|
||||
{
|
||||
if( t == this )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
stack.push( this );
|
||||
|
||||
@@ -231,7 +261,9 @@ public final class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implemen
|
||||
}
|
||||
|
||||
if( stack.pop() != this )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Recursion detected." );
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -61,14 +61,18 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
{
|
||||
PartP2PRedstone in = this.getInput();
|
||||
if( in != null )
|
||||
{
|
||||
this.putInput( in.power );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void putInput( Object o )
|
||||
{
|
||||
if( this.recursive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.recursive = true;
|
||||
if( this.output && this.proxy.isActive() )
|
||||
@@ -160,13 +164,17 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
{
|
||||
int srcSide = this.side.ordinal();
|
||||
if( b instanceof BlockRedstoneWire )
|
||||
{
|
||||
srcSide = 1;
|
||||
}
|
||||
this.power = b.isProvidingStrongPower( this.tile.getWorldObj(), x, y, z, srcSide );
|
||||
this.power = Math.max( this.power, b.isProvidingWeakPower( this.tile.getWorldObj(), x, y, z, srcSide ) );
|
||||
this.sendToOutput( this.power );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendToOutput( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,14 +84,18 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
public T getInput()
|
||||
{
|
||||
if( this.freq == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
PartP2PTunnel tunnel;
|
||||
try
|
||||
{
|
||||
tunnel = this.proxy.getP2P().getInput( this.freq );
|
||||
if( this.getClass().isInstance( tunnel ) )
|
||||
{
|
||||
return (T) tunnel;
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
@@ -103,7 +107,9 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
public TunnelCollection<T> getOutputs() throws GridAccessException
|
||||
{
|
||||
if( this.proxy.isActive() )
|
||||
{
|
||||
return (TunnelCollection<T>) this.proxy.getP2P().getOutputs( this.freq, this.getClass() );
|
||||
}
|
||||
return new TunnelCollection( new ArrayList(), this.getClass() );
|
||||
}
|
||||
|
||||
@@ -179,7 +185,9 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
public ItemStack getItemStack( PartItemStack type )
|
||||
{
|
||||
if( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
|
||||
{
|
||||
return super.getItemStack( type );
|
||||
}
|
||||
|
||||
final Optional<ItemStack> maybeMEStack = AEApi.instance().definitions().parts().p2PTunnelME().maybeStack( 1 );
|
||||
if( maybeMEStack.isPresent() )
|
||||
@@ -380,7 +388,9 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
this.output = false;
|
||||
|
||||
if( wasOutput || this.freq == 0 )
|
||||
{
|
||||
newFreq = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -180,7 +180,9 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
if( connections.destroy )
|
||||
{
|
||||
for( TunnelConnection cw : this.connection.connections.values() )
|
||||
{
|
||||
cw.c.destroy();
|
||||
}
|
||||
|
||||
this.connection.connections.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user