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
@@ -60,32 +60,32 @@ import appeng.util.Platform;
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
{
public CableBusContainer cb = new CableBusContainer( this );
private CableBusContainer cb = new CableBusContainer( this );
/**
* Immibis MB Support
*/
boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
private boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
private int oldLV = -1; // on re-calculate light when it changes
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileCableBus( final NBTTagCompound data )
{
this.cb.readFromNBT( data );
this.getCableBus().readFromNBT( data );
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TileCableBus( final NBTTagCompound data )
{
this.cb.writeToNBT( data );
this.getCableBus().writeToNBT( data );
}
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileCableBus( final ByteBuf data ) throws IOException
{
final boolean ret = this.cb.readFromStream( data );
final boolean ret = this.getCableBus().readFromStream( data );
final int newLV = this.cb.getLightValue();
final int newLV = this.getCableBus().getLightValue();
if( newLV != this.oldLV )
{
this.oldLV = newLV;
@@ -98,11 +98,11 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
protected void updateTileSetting()
{
if( this.cb.requiresDynamicRender )
if( this.getCableBus().isRequiresDynamicRender() )
{
try
{
final TileCableBus tcb = (TileCableBus) BlockCableBus.tesrTile.newInstance();
final TileCableBus tcb = (TileCableBus) BlockCableBus.getTesrTile().newInstance();
tcb.copyFrom( this );
this.getWorld().setTileEntity( this.pos, tcb );
}
@@ -115,16 +115,16 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
protected void copyFrom( final TileCableBus oldTile )
{
final CableBusContainer tmpCB = this.cb;
this.cb = oldTile.cb;
final CableBusContainer tmpCB = this.getCableBus();
this.setCableBus( oldTile.getCableBus() );
this.oldLV = oldTile.oldLV;
oldTile.cb = tmpCB;
oldTile.setCableBus( tmpCB );
}
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileCableBus( final ByteBuf data ) throws IOException
{
this.cb.writeToStream( data );
this.getCableBus().writeToStream( data );
}
@Override
@@ -137,7 +137,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
public void invalidate()
{
super.invalidate();
this.cb.removeFromWorld();
this.getCableBus().removeFromWorld();
}
@Override
@@ -150,20 +150,20 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public IGridNode getGridNode( final AEPartLocation dir )
{
return this.cb.getGridNode( dir );
return this.getCableBus().getGridNode( dir );
}
@Override
public AECableType getCableConnectionType( final AEPartLocation side )
{
return this.cb.getCableConnectionType( side );
return this.getCableBus().getCableConnectionType( side );
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
this.cb.removeFromWorld();
this.getCableBus().removeFromWorld();
}
@Override
@@ -174,7 +174,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
return;
}
final int newLV = this.cb.getLightValue();
final int newLV = this.getCableBus().getLightValue();
if( newLV != this.oldLV )
{
this.oldLV = newLV;
@@ -194,20 +194,20 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public void getDrops( final World w, final BlockPos pos, final List drops )
{
this.cb.getDrops( drops );
this.getCableBus().getDrops( drops );
}
@Override
public void getNoDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
{
this.cb.getNoDrops( drops );
this.getCableBus().getNoDrops( drops );
}
@Override
public void onReady()
{
super.onReady();
if( this.cb.isEmpty() )
if( this.getCableBus().isEmpty() )
{
if( this.worldObj.getTileEntity( this.pos ) == this )
{
@@ -216,32 +216,32 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
else
{
this.cb.addToWorld();
this.getCableBus().addToWorld();
}
}
@Override
public boolean requiresTESR()
{
return this.cb.requiresDynamicRender;
return this.getCableBus().isRequiresDynamicRender();
}
@Override
public IFacadeContainer getFacadeContainer()
{
return this.cb.getFacadeContainer();
return this.getCableBus().getFacadeContainer();
}
@Override
public boolean canAddPart( final ItemStack is, final AEPartLocation side )
{
return this.cb.canAddPart( is, side );
return this.getCableBus().canAddPart( is, side );
}
@Override
public AEPartLocation addPart( final ItemStack is, final AEPartLocation side, final EntityPlayer player )
{
return this.cb.addPart( is, side, player );
return this.getCableBus().addPart( is, side, player );
}
@Override
@@ -253,13 +253,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public IPart getPart( final EnumFacing side )
{
return this.cb.getPart( side );
return this.getCableBus().getPart( side );
}
@Override
public void removePart( final AEPartLocation side, final boolean suppressUpdate )
{
this.cb.removePart( side, suppressUpdate );
this.getCableBus().removePart( side, suppressUpdate );
}
@Override
@@ -271,13 +271,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public AEColor getColor()
{
return this.cb.getColor();
return this.getCableBus().getColor();
}
@Override
public void clearContainer()
{
this.cb = new CableBusContainer( this );
this.setCableBus( new CableBusContainer( this ) );
}
@Override
@@ -285,17 +285,17 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
{
return !this.ImmibisMicroblocks_isSideOpen( side );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity e, final boolean visual )
{
return this.cb.getSelectedBoundingBoxesFromPool( false, true, e, visual );
return this.getCableBus().getSelectedBoundingBoxesFromPool( false, true, e, visual );
}
@Override
public SelectedPart selectPart( final Vec3 pos )
{
return this.cb.selectPart( pos );
return this.getCableBus().selectPart( pos );
}
@Override
@@ -313,19 +313,19 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public boolean hasRedstone( final AEPartLocation side )
{
return this.cb.hasRedstone( side );
return this.getCableBus().hasRedstone( side );
}
@Override
public boolean isEmpty()
{
return this.cb.isEmpty();
return this.getCableBus().isEmpty();
}
@Override
public Set<LayerFlags> getLayerFlags()
{
return this.cb.getLayerFlags();
return this.getCableBus().getLayerFlags();
}
@Override
@@ -342,7 +342,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
this.getWorld().setBlockToAir( this.pos );
}
@Override
public void addCollidingBlockToList(
final World w,
@@ -369,17 +369,17 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public boolean isInWorld()
{
return this.cb.isInWorld();
return this.getCableBus().isInWorld();
}
public boolean ImmibisMicroblocks_isSideOpen( final EnumFacing side )
private boolean ImmibisMicroblocks_isSideOpen( final EnumFacing side )
{
return true;
}
public void ImmibisMicroblocks_onMicroblocksChanged()
{
this.cb.updateConnections();
this.getCableBus().updateConnections();
}
@Override
@@ -388,10 +388,17 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
final AEColor colour,
final EntityPlayer who )
{
return this.cb.recolourBlock( side, colour, who );
return this.getCableBus().recolourBlock( side, colour, who );
}
public CableBusContainer getCableBus()
{
return this.cb;
}
private void setCableBus( final CableBusContainer cb )
{
this.cb = cb;
}
}
@@ -28,11 +28,11 @@ public class TileCableBusTESR extends TileCableBus
@Override
protected void updateTileSetting()
{
if( !this.cb.requiresDynamicRender )
if( !this.getCableBus().isRequiresDynamicRender() )
{
try
{
final TileCableBus tcb = (TileCableBus) BlockCableBus.noTesrTile.newInstance();
final TileCableBus tcb = (TileCableBus) BlockCableBus.getNoTesrTile().newInstance();
tcb.copyFrom( this );
this.getWorld().setTileEntity( this.pos, tcb );
}
@@ -52,10 +52,10 @@ public class TileController extends AENetworkPowerTile
public TileController()
{
this.internalMaxPower = 8000;
this.internalPublicPowerStorage = true;
this.gridProxy.setIdlePowerUsage( 3 );
this.gridProxy.setFlags( GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY );
this.setInternalMaxPower( 8000 );
this.setInternalPublicPowerStorage( true );
this.getProxy().setIdlePowerUsage( 3 );
this.getProxy().setFlags( GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY );
}
@Override
@@ -89,11 +89,11 @@ public class TileController extends AENetworkPowerTile
{
if( this.isValid )
{
this.gridProxy.setValidSides( EnumSet.allOf( EnumFacing.class ) );
this.getProxy().setValidSides( EnumSet.allOf( EnumFacing.class ) );
}
else
{
this.gridProxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
}
this.updateMeta();
@@ -103,20 +103,20 @@ public class TileController extends AENetworkPowerTile
private void updateMeta()
{
if( !this.gridProxy.isReady() )
if( !this.getProxy().isReady() )
{
return;
}
ControllerBlockState metaState = ControllerBlockState.OFFLINE;
try
{
if( this.gridProxy.getEnergy().isNetworkPowered() )
if( this.getProxy().getEnergy().isNetworkPowered() )
{
metaState = ControllerBlockState.ONLINE;
if( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
if( this.getProxy().getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
{
metaState = ControllerBlockState.CONFLICTED;
}
@@ -126,12 +126,12 @@ public class TileController extends AENetworkPowerTile
{
metaState = ControllerBlockState.OFFLINE;
}
if( this.checkController( this.pos ) && this.worldObj.getBlockState( this.pos ).getValue( BlockController.CONTROLLER_STATE ) != metaState )
{
this.worldObj.setBlockState( this.pos, this.worldObj.getBlockState( this.pos ).withProperty( BlockController.CONTROLLER_STATE, metaState ) );
}
}
@Override
@@ -139,7 +139,7 @@ public class TileController extends AENetworkPowerTile
{
try
{
return this.gridProxy.getEnergy().getEnergyDemand( 8000 );
return this.getProxy().getEnergy().getEnergyDemand( 8000 );
}
catch( final GridAccessException e )
{
@@ -153,7 +153,7 @@ public class TileController extends AENetworkPowerTile
{
try
{
final double ret = this.gridProxy.getEnergy().injectPower( power, mode );
final double ret = this.getProxy().getEnergy().injectPower( power, mode );
if( mode == Actionable.SIMULATE )
{
return ret;
@@ -172,7 +172,7 @@ public class TileController extends AENetworkPowerTile
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
}
catch( final GridAccessException e )
{
@@ -222,7 +222,7 @@ public class TileController extends AENetworkPowerTile
{
return this.worldObj.getTileEntity( pos ) instanceof TileController;
}
return false;
}
}
@@ -33,7 +33,7 @@ public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerSto
public TileCreativeEnergyCell()
{
this.gridProxy.setIdlePowerUsage( 0 );
this.getProxy().setIdlePowerUsage( 0 );
}
@Override
@@ -24,6 +24,6 @@ public class TileDenseEnergyCell extends TileEnergyCell
public TileDenseEnergyCell()
{
this.internalMaxPower = 200000 * 8;
this.setInternalMaxPower( 200000 * 8 );
}
}
@@ -36,13 +36,13 @@ import appeng.tile.inventory.InvOperation;
public class TileEnergyAcceptor extends AENetworkPowerTile
{
static final AppEngInternalInventory INTERNAL_INVENTORY = new AppEngInternalInventory( null, 0 );
final int[] sides = {};
private static final AppEngInternalInventory INTERNAL_INVENTORY = new AppEngInternalInventory( null, 0 );
private final int[] sides = {};
public TileEnergyAcceptor()
{
this.gridProxy.setIdlePowerUsage( 0.0 );
this.internalMaxPower = 0;
this.getProxy().setIdlePowerUsage( 0.0 );
this.setInternalMaxPower( 0 );
}
@Override
@@ -72,12 +72,12 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
{
try
{
final IEnergyGrid grid = this.gridProxy.getEnergy();
final IEnergyGrid grid = this.getProxy().getEnergy();
return grid.getEnergyDemand( maxRequired );
}
catch( final GridAccessException e )
{
return this.internalMaxPower;
return this.getInternalMaxPower();
}
}
@@ -86,7 +86,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
{
try
{
final IEnergyGrid grid = this.gridProxy.getEnergy();
final IEnergyGrid grid = this.getProxy().getEnergy();
final double leftOver = grid.injectPower( power, mode );
if( mode == Actionable.SIMULATE )
{
@@ -39,15 +39,14 @@ import appeng.util.SettingsFrom;
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
{
protected double internalCurrentPower = 0.0;
protected double internalMaxPower = 200000.0;
private double internalCurrentPower = 0.0;
private double internalMaxPower = 200000.0;
private byte currentMeta = -1;
public TileEnergyCell()
{
this.gridProxy.setIdlePowerUsage( 0 );
this.getProxy().setIdlePowerUsage( 0 );
}
@Override
@@ -60,8 +59,8 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
public void onReady()
{
super.onReady();
final int value = ( Integer ) this.worldObj.getBlockState( this.pos ).getValue( BlockEnergyCell.ENERGY_STORAGE );
this.currentMeta = (byte)value;
final int value = (Integer) this.worldObj.getBlockState( this.pos ).getValue( BlockEnergyCell.ENERGY_STORAGE );
this.currentMeta = (byte) value;
this.changePowerLevel();
}
@@ -72,7 +71,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
return;
}
byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.internalMaxPower ) );
byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.getInternalMaxPower() ) );
if( boundMetadata > 7 )
{
@@ -86,7 +85,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
if( this.currentMeta != boundMetadata )
{
this.currentMeta = boundMetadata;
this.worldObj.setBlockState( this.pos, this.worldObj.getBlockState( this.pos ).withProperty( BlockEnergyCell.ENERGY_STORAGE, (int)boundMetadata ) );
this.worldObj.setBlockState( this.pos, this.worldObj.getBlockState( this.pos ).withProperty( BlockEnergyCell.ENERGY_STORAGE, (int) boundMetadata ) );
}
}
@@ -127,7 +126,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
{
final NBTTagCompound tag = new NBTTagCompound();
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
tag.setDouble( "internalMaxPower", this.internalMaxPower ); // used for tool tip.
tag.setDouble( "internalMaxPower", this.getInternalMaxPower() ); // used for tool tip.
return tag;
}
return null;
@@ -139,9 +138,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
if( mode == Actionable.SIMULATE )
{
final double fakeBattery = this.internalCurrentPower + amt;
if( fakeBattery > this.internalMaxPower )
if( fakeBattery > this.getInternalMaxPower() )
{
return fakeBattery - this.internalMaxPower;
return fakeBattery - this.getInternalMaxPower();
}
return 0;
@@ -149,14 +148,14 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
{
this.gridProxy.getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
this.getProxy().getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
}
this.internalCurrentPower += amt;
if( this.internalCurrentPower > this.internalMaxPower )
if( this.internalCurrentPower > this.getInternalMaxPower() )
{
amt = this.internalCurrentPower - this.internalMaxPower;
this.internalCurrentPower = this.internalMaxPower;
amt = this.internalCurrentPower - this.getInternalMaxPower();
this.internalCurrentPower = this.getInternalMaxPower();
this.changePowerLevel();
return amt;
@@ -169,7 +168,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
@Override
public double getAEMaxPower()
{
return this.internalMaxPower;
return this.getInternalMaxPower();
}
@Override
@@ -207,13 +206,13 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
return this.internalCurrentPower;
}
final boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001;
if( wasFull && amt > 0.001 )
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
}
catch( final GridAccessException ignored )
{
@@ -235,4 +234,14 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
this.changePowerLevel();
return amt;
}
private double getInternalMaxPower()
{
return this.internalMaxPower;
}
void setInternalMaxPower( final double internalMaxPower )
{
this.internalMaxPower = internalMaxPower;
}
}
@@ -53,22 +53,22 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
public static final int POWERED_FLAG = 1;
public static final int CHANNEL_FLAG = 2;
final int[] sides = { 0 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
private final int[] sides = { 0 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
public int clientFlags = 0;
private int clientFlags = 0;
public TileWireless()
{
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.gridProxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
}
@Override
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
{
super.setOrientation( inForward, inUp );
this.gridProxy.setValidSides( EnumSet.of( this.getForward().getOpposite() ) );
this.getProxy().setValidSides( EnumSet.of( this.getForward().getOpposite() ) );
}
@MENetworkEventSubscribe
@@ -86,27 +86,27 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileWireless( final ByteBuf data )
{
final int old = this.clientFlags;
this.clientFlags = data.readByte();
final int old = this.getClientFlags();
this.setClientFlags( data.readByte() );
return old != this.clientFlags;
return old != this.getClientFlags();
}
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileWireless( final ByteBuf data )
{
this.clientFlags = 0;
this.setClientFlags( 0 );
try
{
if( this.gridProxy.getEnergy().isNetworkPowered() )
if( this.getProxy().getEnergy().isNetworkPowered() )
{
this.clientFlags |= POWERED_FLAG;
this.setClientFlags( this.getClientFlags() | POWERED_FLAG );
}
if( this.gridProxy.getNode().meetsChannelRequirements() )
if( this.getProxy().getNode().meetsChannelRequirements() )
{
this.clientFlags |= CHANNEL_FLAG;
this.setClientFlags( this.getClientFlags() | CHANNEL_FLAG );
}
}
catch( final GridAccessException e )
@@ -114,7 +114,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
// meh
}
data.writeByte( (byte) this.clientFlags );
data.writeByte( (byte) this.getClientFlags() );
}
@Override
@@ -162,7 +162,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
private void updatePower()
{
this.gridProxy.setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
this.getProxy().setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
}
private int getBoosters()
@@ -188,10 +188,10 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
{
if( Platform.isClient() )
{
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
return this.isPowered() && ( CHANNEL_FLAG == ( this.getClientFlags() & CHANNEL_FLAG ) );
}
return this.gridProxy.isActive();
return this.getProxy().isActive();
}
@Override
@@ -199,7 +199,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
{
try
{
return this.gridProxy.getGrid();
return this.getProxy().getGrid();
}
catch( final GridAccessException e )
{
@@ -210,6 +210,16 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
@Override
public boolean isPowered()
{
return POWERED_FLAG == ( this.clientFlags & POWERED_FLAG );
return POWERED_FLAG == ( this.getClientFlags() & POWERED_FLAG );
}
public int getClientFlags()
{
return this.clientFlags;
}
private void setClientFlags( final int clientFlags )
{
this.clientFlags = clientFlags;
}
}