Reduces visibility of internal fields/methods

Reduces the visibility of all fields to private and create setters/getters
when necessary. Exceptions are fields with GuiSync as these need to be
public.

Reduces the visibility of internal methods to private/protected/default when possible.
This commit is contained in:
yueh
2015-10-08 15:42:42 +02:00
parent f054bd699b
commit e94a0cfccf
497 changed files with 7865 additions and 6908 deletions
@@ -262,4 +262,4 @@ package appeng.parts.p2p;
// {
// return ic2.api.energy.EnergyNet.instance.getTierFromPower( voltage );
// }
//}
// }
@@ -54,13 +54,13 @@ import appeng.util.inv.WrapperMCISidedInventory;
// TODO: BC Integration
//@Interface( iface = "buildcraft.api.transport.IPipeConnection", iname = IntegrationType.BuildCraftTransport )
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipeConnection,*/ ISidedInventory, IGridTickable
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPipeConnection, */ISidedInventory, IGridTickable
{
final LinkedList<IInventory> which = new LinkedList<IInventory>();
int oldSize = 0;
boolean requested;
IInventory cachedInv;
private final LinkedList<IInventory> which = new LinkedList<IInventory>();
private int oldSize = 0;
private boolean requested;
private IInventory cachedInv;
public PartP2PItems( final ItemStack is )
{
@@ -72,13 +72,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
{
this.cachedInv = null;
final PartP2PItems input = this.getInput();
if( input != null && this.output )
if( input != null && this.isOutput() )
{
input.onTunnelNetworkChange();
}
}
IInventory getDestination()
private IInventory getDestination()
{
this.requested = true;
@@ -118,13 +118,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
return this.cachedInv = new WrapperChainedInventory( outs );
}
IInventory getOutputInv()
private IInventory getOutputInv()
{
IInventory output = null;
if( this.proxy.isActive() )
if( this.getProxy().isActive() )
{
final TileEntity te = this.tile.getWorld().getTileEntity( this.tile.getPos().offset( this.side.getFacing() ) );
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
if( this.which.contains( this ) )
{
@@ -136,18 +136,18 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.BuildCraftTransport ) )
{
final IBuildCraftTransport buildcraft = (IBuildCraftTransport) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.BuildCraftTransport );
if( buildcraft.isPipe( te, this.side.getOpposite().getFacing() ) )
if( buildcraft.isPipe( te, this.getSide().getOpposite().getFacing() ) )
{
try
{
output = new WrapperBCPipe( te, this.side.getFacing().getOpposite() );
output = new WrapperBCPipe( te, this.getSide().getFacing().getOpposite() );
}
catch( final Throwable ignore )
{
}
}
}
/*
* if ( AppEng.INSTANCE.isIntegrationEnabled( "TE" ) ) { ITE thermal = (ITE) AppEng.INSTANCE.getIntegration(
* "TE" ); if ( thermal != null ) { if ( thermal.isPipe( te, side.getOpposite() ) ) { try { output = new
@@ -162,7 +162,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
}
else if( te instanceof ISidedInventory )
{
output = new WrapperMCISidedInventory( (ISidedInventory) te, this.side.getFacing().getOpposite() );
output = new WrapperMCISidedInventory( (ISidedInventory) te, this.getSide().getFacing().getOpposite() );
}
else if( te instanceof IInventory )
{
@@ -179,7 +179,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
return new TickingRequest( TickRates.ItemTunnel.min, TickRates.ItemTunnel.max, false, false );
return new TickingRequest( TickRates.ItemTunnel.getMin(), TickRates.ItemTunnel.getMax(), false, false );
}
@Override
@@ -199,7 +199,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
@MENetworkEventSubscribe
public void changeStateA( final MENetworkBootingStatusChange bs )
{
if( !this.output )
if( !this.isOutput() )
{
this.cachedInv = null;
final int olderSize = this.oldSize;
@@ -214,7 +214,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
@MENetworkEventSubscribe
public void changeStateB( final MENetworkChannelsChanged bs )
{
if( !this.output )
if( !this.isOutput() )
{
this.cachedInv = null;
final int olderSize = this.oldSize;
@@ -229,7 +229,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
@MENetworkEventSubscribe
public void changeStateC( final MENetworkPowerStatusChange bs )
{
if( !this.output )
if( !this.isOutput() )
{
this.cachedInv = null;
final int olderSize = this.oldSize;
@@ -244,7 +244,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
@Override
public void onTunnelNetworkChange()
{
if( !this.output )
if( !this.isOutput() )
{
this.cachedInv = null;
final int olderSize = this.oldSize;
@@ -337,12 +337,12 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
}
@Override
public void openInventory( final EntityPlayer p)
public void openInventory( final EntityPlayer p )
{
}
@Override
public void closeInventory( final EntityPlayer p)
public void closeInventory( final EntityPlayer p )
{
}
@@ -375,12 +375,12 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
return 0;
}
// @Override
// @Method( iname = IntegrationType.BuildCraftTransport )
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
// {
// return 0;
// }
// @Override
// @Method( iname = IntegrationType.BuildCraftTransport )
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
// {
// return 0;
// }
@Override
public void setField(
@@ -409,10 +409,10 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /*IPipe
}
// TODO: BC Integration
// @Override
// @Method( iname = "BuildCraftTransport" )
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
// {
// return this.side == with && type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
// }
// @Override
// @Method( iname = "BuildCraftTransport" )
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
// {
// return this.side == with && type == PipeType.ITEM ? ConnectOverride.CONNECT : ConnectOverride.DEFAULT;
// }
}
@@ -40,8 +40,8 @@ import appeng.me.GridAccessException;
public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTickable
{
int lastValue = 0;
float opacity = -1;
private int lastValue = 0;
private float opacity = -1;
public PartP2PLight( final ItemStack is )
{
@@ -66,7 +66,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
public void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
data.writeInt( this.output ? this.lastValue : 0 );
data.writeInt( this.isOutput() ? this.lastValue : 0 );
}
@Override
@@ -74,13 +74,13 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
{
super.readFromStream( data );
this.lastValue = data.readInt();
this.output = this.lastValue > 0;
this.setOutput( this.lastValue > 0 );
return false;
}
private boolean doWork()
{
if( this.output )
if( this.isOutput() )
{
return false;
}
@@ -88,9 +88,9 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
final TileEntity te = this.getTile();
final World w = te.getWorld();
final int newLevel = w.getLight( te.getPos().offset( this.side.getFacing() ) );
final int newLevel = w.getLight( te.getPos().offset( this.getSide().getFacing() ) );
if( this.lastValue != newLevel && this.proxy.isActive() )
if( this.lastValue != newLevel && this.getProxy().isActive() )
{
this.lastValue = newLevel;
try
@@ -116,7 +116,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
this.doWork();
if( this.output )
if( this.isOutput() )
{
this.getHost().markForUpdate();
}
@@ -125,7 +125,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
@Override
public int getLightLevel()
{
if( this.output && this.isPowered() )
if( this.isOutput() && this.isPowered() )
{
return this.blockLight( this.lastValue );
}
@@ -133,7 +133,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
return 0;
}
public void setLightLevel( final int out )
private void setLightLevel( final int out )
{
this.lastValue = out;
this.getHost().markForUpdate();
@@ -144,7 +144,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
if( this.opacity < 0 )
{
final TileEntity te = this.getTile();
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( this.side.getFacing() ) );
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( this.getSide().getFacing() ) );
}
return (int) ( emit * ( this.opacity / 255.0f ) );
@@ -178,10 +178,10 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
@Override
public void onTunnelNetworkChange()
{
if( this.output )
if( this.isOutput() )
{
final PartP2PLight src = this.getInput();
if( src != null && src.proxy.isActive() )
if( src != null && src.getProxy().isActive() )
{
this.setLightLevel( src.lastValue );
}
@@ -199,7 +199,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
return new TickingRequest( TickRates.LightTunnel.min, TickRates.LightTunnel.max, false, false );
return new TickingRequest( TickRates.LightTunnel.getMin(), TickRates.LightTunnel.getMax(), false, false );
}
@Override
@@ -37,10 +37,10 @@ import appeng.me.GridAccessException;
public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFluidHandler
{
static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
private static final ThreadLocal<Stack<PartP2PLiquids>> DEPTH = new ThreadLocal<Stack<PartP2PLiquids>>();
private static final FluidTankInfo[] ACTIVE_TANK = { new FluidTankInfo( null, 10000 ) };
private static final FluidTankInfo[] INACTIVE_TANK = { new FluidTankInfo( null, 0 ) };
IFluidHandler cachedTank;
private IFluidHandler cachedTank;
private int tmpUsed;
public PartP2PLiquids( final ItemStack is )
@@ -63,7 +63,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
public void onNeighborChanged()
{
this.cachedTank = null;
if( this.output )
if( this.isOutput() )
{
final PartP2PLiquids in = this.getInput();
if( in != null )
@@ -98,7 +98,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.side.getFacing().getOpposite(), resource.copy(), false );
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), resource.copy(), false );
}
else
{
@@ -153,7 +153,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
final IFluidHandler tank = l.getTarget();
if( tank != null )
{
l.tmpUsed = tank.fill( l.side.getFacing().getOpposite(), insert.copy(), true );
l.tmpUsed = tank.fill( l.getSide().getFacing().getOpposite(), insert.copy(), true );
}
else
{
@@ -184,7 +184,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
return s;
}
List<PartP2PLiquids> getOutputs( final Fluid input )
private List<PartP2PLiquids> getOutputs( final Fluid input )
{
final List<PartP2PLiquids> outs = new LinkedList<PartP2PLiquids>();
@@ -195,7 +195,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
final IFluidHandler handler = l.getTarget();
if( handler != null )
{
if( handler.canFill( l.side.getFacing().getOpposite(), input ) )
if( handler.canFill( l.getSide().getFacing().getOpposite(), input ) )
{
outs.add( l );
}
@@ -210,9 +210,9 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
return outs;
}
IFluidHandler getTarget()
private IFluidHandler getTarget()
{
if( !this.proxy.isActive() )
if( !this.getProxy().isActive() )
{
return null;
}
@@ -222,7 +222,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
return this.cachedTank;
}
final TileEntity te = this.tile.getWorld().getTileEntity( this.tile.getPos().offset( this.side.getFacing() ) );
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
if( te instanceof IFluidHandler )
{
return this.cachedTank = (IFluidHandler) te;
@@ -246,7 +246,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
@Override
public boolean canFill( final EnumFacing from, final Fluid fluid )
{
return !this.output && from == this.side.getFacing() && !this.getOutputs( fluid ).isEmpty();
return !this.isOutput() && from == this.getSide().getFacing() && !this.getOutputs( fluid ).isEmpty();
}
@Override
@@ -258,7 +258,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
@Override
public FluidTankInfo[] getTankInfo( final EnumFacing from )
{
if( from == this.side.getFacing() )
if( from == this.getSide().getFacing() )
{
return this.getTank();
}
@@ -267,7 +267,7 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
private FluidTankInfo[] getTank()
{
if( this.output )
if( this.isOutput() )
{
final PartP2PLiquids tun = this.getInput();
if( tun != null )
@@ -250,4 +250,4 @@ package appeng.parts.p2p;
// return null;
// }
// }
//}
// }
@@ -171,4 +171,4 @@ package appeng.parts.p2p;
// }
// }
//
//}
// }
@@ -38,8 +38,8 @@ import appeng.util.Platform;
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
{
int power;
boolean recursive = false;
private int power;
private boolean recursive = false;
public PartP2PRedstone( final ItemStack is )
{
@@ -52,9 +52,9 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
this.setNetworkReady();
}
public void setNetworkReady()
private void setNetworkReady()
{
if( this.output )
if( this.isOutput() )
{
final PartP2PRedstone in = this.getInput();
if( in != null )
@@ -64,7 +64,7 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
}
}
protected void putInput( final Object o )
private void putInput( final Object o )
{
if( this.recursive )
{
@@ -72,7 +72,7 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
}
this.recursive = true;
if( this.output && this.proxy.isActive() )
if( this.isOutput() && this.getProxy().isActive() )
{
final int newPower = (Integer) o;
if( this.power != newPower )
@@ -84,15 +84,15 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
this.recursive = false;
}
public void notifyNeighbors()
private void notifyNeighbors()
{
final World worldObj = this.tile.getWorld();
final World worldObj = this.getTile().getWorld();
Platform.notifyBlocksOfNeighbors( worldObj, this.tile.getPos());
Platform.notifyBlocksOfNeighbors( worldObj, this.getTile().getPos() );
// and this cause sometimes it can go thought walls.
for ( final EnumFacing face : EnumFacing.VALUES )
Platform.notifyBlocksOfNeighbors( worldObj, this.tile.getPos().offset( face ) );
for( final EnumFacing face : EnumFacing.VALUES )
Platform.notifyBlocksOfNeighbors( worldObj, this.getTile().getPos().offset( face ) );
}
@MENetworkEventSubscribe
@@ -135,22 +135,22 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
@Override
public void onNeighborChanged()
{
if( !this.output )
if( !this.isOutput() )
{
final BlockPos target = this.tile.getPos().offset( this.side.getFacing() );
final BlockPos target = this.getTile().getPos().offset( this.getSide().getFacing() );
final IBlockState state = this.tile.getWorld().getBlockState( target );
final IBlockState state = this.getTile().getWorld().getBlockState( target );
final Block b = state.getBlock();
if( b != null && !this.output )
if( b != null && !this.isOutput() )
{
EnumFacing srcSide = this.side.getFacing();
EnumFacing srcSide = this.getSide().getFacing();
if( b instanceof BlockRedstoneWire )
{
srcSide = EnumFacing.UP;
}
this.power = b.isProvidingStrongPower( this.tile.getWorld(), target,state, srcSide );
this.power = Math.max( this.power, b.isProvidingWeakPower( this.tile.getWorld(), target, state, srcSide ) );
this.power = b.isProvidingStrongPower( this.getTile().getWorld(), target, state, srcSide );
this.power = Math.max( this.power, b.isProvidingWeakPower( this.getTile().getWorld(), target, state, srcSide ) );
this.sendToOutput( this.power );
}
else
@@ -169,13 +169,13 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
@Override
public int isProvidingStrongPower()
{
return this.output ? this.power : 0;
return this.isOutput() ? this.power : 0;
}
@Override
public int isProvidingWeakPower()
{
return this.output ? this.power : 0;
return this.isOutput() ? this.power : 0;
}
private void sendToOutput( final int power )
@@ -62,8 +62,8 @@ import com.google.common.base.Optional;
public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
{
private final TunnelCollection type = new TunnelCollection<T>( null, this.getClass() );
public boolean output;
public long freq;
private boolean output;
private long freq;
public PartP2PTunnel( final ItemStack is )
{
@@ -81,16 +81,16 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
return null;
}
public T getInput()
T getInput()
{
if( this.freq == 0 )
if( this.getFrequency() == 0 )
{
return null;
}
try
{
final PartP2PTunnel tunnel = this.proxy.getP2P().getInput( this.freq );
final PartP2PTunnel tunnel = this.getProxy().getP2P().getInput( this.getFrequency() );
if( this.getClass().isInstance( tunnel ) )
{
return (T) tunnel;
@@ -103,11 +103,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
return null;
}
public TunnelCollection<T> getOutputs() throws GridAccessException
TunnelCollection<T> getOutputs() throws GridAccessException
{
if( this.proxy.isActive() )
if( this.getProxy().isActive() )
{
return (TunnelCollection<T>) this.proxy.getP2P().getOutputs( this.freq, this.getClass() );
return (TunnelCollection<T>) this.getProxy().getP2P().getOutputs( this.getFrequency(), this.getClass() );
}
return new TunnelCollection( new ArrayList(), this.getClass() );
}
@@ -124,19 +124,19 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
@SideOnly( Side.CLIENT )
public void renderInventory( final IPartRenderHelper rh, final ModelGenerator renderer )
{
rh.setTexture( this.getTypeTexture(renderer) );
rh.setTexture( this.getTypeTexture( renderer ) );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), renderer.getIcon( this.is ), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), renderer.getIcon( this.getItemStack() ), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
}
/**
* @param renderer
* @param renderer
* @return If enabled it returns the icon of an AE quartz block, else vanilla quartz block icon
*/
protected IAESprite getTypeTexture( final ModelGenerator renderer )
@@ -144,11 +144,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().quartz().maybeBlock();
if( maybeBlock.isPresent() )
{
return renderer.getIcon( new ItemStack(maybeBlock.get()) );
return renderer.getIcon( new ItemStack( maybeBlock.get() ) );
}
else
{
return renderer.getIcon( new ItemStack(Blocks.quartz_block) );
return renderer.getIcon( new ItemStack( Blocks.quartz_block ) );
}
}
@@ -156,12 +156,12 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
@SideOnly( Side.CLIENT )
public void renderStatic( final BlockPos pos, final IPartRenderHelper rh, final ModelGenerator renderer )
{
rh.setTexture( this.getTypeTexture(renderer) );
rh.setTexture( this.getTypeTexture( renderer ) );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), renderer.getIcon( this.is ), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), renderer.getIcon( this.getItemStack() ), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
@@ -201,16 +201,16 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.output = data.getBoolean( "output" );
this.freq = data.getLong( "freq" );
this.setOutput( data.getBoolean( "output" ) );
this.setFrequency( data.getLong( "freq" ) );
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "output", this.output );
data.setLong( "freq", this.freq );
data.setBoolean( "output", this.isOutput() );
data.setLong( "freq", this.getFrequency() );
}
@Override
@@ -249,18 +249,18 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType );
if( testPart instanceof PartP2PTunnel )
{
this.getHost().removePart( this.side, true );
final AEPartLocation dir = this.getHost().addPart( newType, this.side, player );
this.getHost().removePart( this.getSide(), true );
final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player );
final IPart newBus = this.getHost().getPart( dir );
if( newBus instanceof PartP2PTunnel )
{
final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
newTunnel.output = true;
newTunnel.setOutput( true );
try
{
final P2PCache p2p = newTunnel.proxy.getP2P();
final P2PCache p2p = newTunnel.getProxy().getP2P();
p2p.updateFreq( newTunnel, freq );
}
catch( final GridAccessException e )
@@ -293,31 +293,31 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
}
break;
/*
case RF_POWER:
for( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
*/
/*
* case RF_POWER:
* for( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() )
* {
* newType = stack;
* }
* break;
*/
case FLUID:
for( final ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
/*
case IC2_POWER:
for( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
*/
/*
* case IC2_POWER:
* for( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() )
* {
* newType = stack;
* }
* break;
*/
case ITEM:
for( final ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() )
{
@@ -338,46 +338,44 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
newType = stack;
}
break;
/*
case COMPUTER_MESSAGE:
for( ItemStack stack : parts.p2PTunnelOpenComputers().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
case PRESSURE:
for( ItemStack stack : parts.p2PTunnelPneumaticCraft().maybeStack( 1 ).asSet() )
{
newType = stack;
}
break;
/*
* case COMPUTER_MESSAGE:
* for( ItemStack stack : parts.p2PTunnelOpenComputers().maybeStack( 1 ).asSet() )
* {
* newType = stack;
* }
* break;
* case PRESSURE:
* for( ItemStack stack : parts.p2PTunnelPneumaticCraft().maybeStack( 1 ).asSet() )
* {
* newType = stack;
* }
* break;
*/
*/
default:
break;
}
if( newType != null && !Platform.isSameItem( newType, this.is ) )
if( newType != null && !Platform.isSameItem( newType, this.getItemStack() ) )
{
final boolean oldOutput = this.output;
final long myFreq = this.freq;
final boolean oldOutput = this.isOutput();
final long myFreq = this.getFrequency();
this.getHost().removePart( this.side, false );
final AEPartLocation dir = this.getHost().addPart( newType, this.side, player );
this.getHost().removePart( this.getSide(), false );
final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player );
final IPart newBus = this.getHost().getPart( dir );
if( newBus instanceof PartP2PTunnel )
{
final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
newTunnel.output = oldOutput;
newTunnel.setOutput( oldOutput );
newTunnel.onTunnelNetworkChange();
try
{
final P2PCache p2p = newTunnel.proxy.getP2P();
final P2PCache p2p = newTunnel.getProxy().getP2P();
p2p.updateFreq( newTunnel, myFreq );
}
catch( final GridAccessException e )
@@ -386,7 +384,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
}
}
Platform.notifyBlocksOfNeighbors( this.tile.getWorld(), this.tile.getPos() );
Platform.notifyBlocksOfNeighbors( this.getTile().getWorld(), this.getTile().getPos() );
return true;
}
}
@@ -403,18 +401,18 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final IMemoryCard mc = (IMemoryCard) is.getItem();
final NBTTagCompound data = new NBTTagCompound();
long newFreq = this.freq;
final boolean wasOutput = this.output;
this.output = false;
long newFreq = this.getFrequency();
final boolean wasOutput = this.isOutput();
this.setOutput( false );
if( wasOutput || this.freq == 0 )
if( wasOutput || this.getFrequency() == 0 )
{
newFreq = System.currentTimeMillis();
}
try
{
this.proxy.getP2P().updateFreq( this, newFreq );
this.getProxy().getP2P().updateFreq( this, newFreq );
}
catch( final GridAccessException e )
{
@@ -427,7 +425,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final String type = p2pItem.getUnlocalizedName();
p2pItem.writeToNBT( data );
data.setLong( "freq", this.freq );
data.setLong( "freq", this.getFrequency() );
mc.setMemoryCardContents( is, type + ".name", data );
mc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
@@ -458,11 +456,31 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
try
{
this.proxy.getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE );
this.getProxy().getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE );
}
catch( final GridAccessException e )
{
// :P
}
}
public long getFrequency()
{
return this.freq;
}
public void setFrequency( final long freq )
{
this.freq = freq;
}
public boolean isOutput()
{
return this.output;
}
void setOutput( final boolean output )
{
this.output = output;
}
}
@@ -49,13 +49,13 @@ import appeng.me.helpers.AENetworkProxy;
public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements IGridTickable
{
public final Connections connection = new Connections( this );
final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
private final Connections connection = new Connections( this );
private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
public PartP2PTunnelME( final ItemStack is )
{
super( is );
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.COMPRESSED_CHANNEL );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.COMPRESSED_CHANNEL );
this.outerProxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.CANNOT_CARRY_COMPRESSED );
}
@@ -77,11 +77,11 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
public void onTunnelNetworkChange()
{
super.onTunnelNetworkChange();
if( !this.output )
if( !this.isOutput() )
{
try
{
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
catch( final GridAccessException e )
{
@@ -133,7 +133,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
return new TickingRequest( TickRates.METunnel.min, TickRates.METunnel.max, true, false );
return new TickingRequest( TickRates.METunnel.getMin(), TickRates.METunnel.getMax(), true, false );
}
@Override
@@ -142,24 +142,24 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
// just move on...
try
{
if( !this.proxy.getPath().isNetworkBooting() )
if( !this.getProxy().getPath().isNetworkBooting() )
{
if( !this.proxy.getEnergy().isNetworkPowered() )
if( !this.getProxy().getEnergy().isNetworkPowered() )
{
this.connection.markDestroy();
TickHandler.INSTANCE.addCallable( this.tile.getWorld(), this.connection );
TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection );
}
else
{
if( this.proxy.isActive() )
if( this.getProxy().isActive() )
{
this.connection.markCreate();
TickHandler.INSTANCE.addCallable( this.tile.getWorld(), this.connection );
TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection );
}
else
{
this.connection.markDestroy();
TickHandler.INSTANCE.addCallable( this.tile.getWorld(), this.connection );
TickHandler.INSTANCE.addCallable( this.getTile().getWorld(), this.connection );
}
}
@@ -176,32 +176,32 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
public void updateConnections( final Connections connections )
{
if( connections.destroy )
if( connections.isDestroy() )
{
for( final TunnelConnection cw : this.connection.connections.values() )
for( final TunnelConnection cw : this.connection.getConnections().values() )
{
cw.c.destroy();
cw.getConnection().destroy();
}
this.connection.connections.clear();
this.connection.getConnections().clear();
}
else if( connections.create )
else if( connections.isCreate() )
{
final Iterator<TunnelConnection> i = this.connection.connections.values().iterator();
final Iterator<TunnelConnection> i = this.connection.getConnections().values().iterator();
while( i.hasNext() )
{
final TunnelConnection cw = i.next();
try
{
if( cw.tunnel.proxy.getGrid() != this.proxy.getGrid() )
if( cw.getTunnel().getProxy().getGrid() != this.getProxy().getGrid() )
{
cw.c.destroy();
cw.getConnection().destroy();
i.remove();
}
else if( !cw.tunnel.proxy.isActive() )
else if( !cw.getTunnel().getProxy().isActive() )
{
cw.c.destroy();
cw.getConnection().destroy();
i.remove();
}
}
@@ -216,7 +216,7 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
{
for( final PartP2PTunnelME me : this.getOutputs() )
{
if( me.proxy.isActive() && connections.connections.get( me.getGridNode() ) == null )
if( me.getProxy().isActive() && connections.getConnections().get( me.getGridNode() ) == null )
{
newSides.add( me );
}
@@ -226,15 +226,15 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
{
try
{
connections.connections.put( me.getGridNode(), new TunnelConnection( me, AEApi.instance().createGridConnection( this.outerProxy.getNode(), me.outerProxy.getNode() ) ) );
connections.getConnections().put( me.getGridNode(), new TunnelConnection( me, AEApi.instance().createGridConnection( this.outerProxy.getNode(), me.outerProxy.getNode() ) ) );
}
catch( final FailedConnection e )
{
final TileEntity start = this.getTile();
final TileEntity end = me.getTile();
AELog.warning( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]",
start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(),
end.getPos().getX(), end.getPos().getY(), end.getPos().getZ() );
AELog.warning( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]",
start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(),
end.getPos().getX(), end.getPos().getY(), end.getPos().getZ() );
// :(
}
}