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
@@ -95,34 +95,34 @@ import appeng.util.item.AEFluidStack;
public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHandler, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, IUpdatePlayerListBox
{
static final ChestNoHandler NO_HANDLER = new ChestNoHandler();
static final int[] SIDES = { 0 };
static final int[] FRONT = { 1 };
static final int[] NO_SLOTS = {};
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
final BaseActionSource mySrc = new MachineSource( this );
final IConfigManager config = new ConfigManager( this );
ItemStack storageType;
long lastStateChange = 0;
int priority = 0;
int state = 0;
boolean wasActive = false;
AEColor paintedColor = AEColor.Transparent;
boolean isCached = false;
private static final ChestNoHandler NO_HANDLER = new ChestNoHandler();
private static final int[] SIDES = { 0 };
private static final int[] FRONT = { 1 };
private static final int[] NO_SLOTS = {};
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
private final BaseActionSource mySrc = new MachineSource( this );
private final IConfigManager config = new ConfigManager( this );
private ItemStack storageType;
private long lastStateChange = 0;
private int priority = 0;
private int state = 0;
private boolean wasActive = false;
private AEColor paintedColor = AEColor.Transparent;
private boolean isCached = false;
private ICellHandler cellHandler;
private MEMonitorHandler itemCell;
private MEMonitorHandler fluidCell;
public TileChest()
{
this.internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.setInternalMaxPower( PowerMultiplier.CONFIG.multiply( 40 ) );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.config.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.config.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
this.internalPublicPowerStorage = true;
this.internalPowerFlow = AccessRestriction.WRITE;
this.setInternalPublicPowerStorage( true );
this.setInternalPowerFlow( AccessRestriction.WRITE );
}
@Override
@@ -132,7 +132,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
}
catch( final GridAccessException e )
{
@@ -163,13 +163,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
this.state &= ~0x40;
}
final boolean currentActive = this.gridProxy.isActive();
final boolean currentActive = this.getProxy().isActive();
if( this.wasActive != currentActive )
{
this.wasActive = currentActive;
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
}
catch( final GridAccessException e )
{
@@ -189,7 +189,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
return 1;
}
public IMEInventoryHandler getHandler( final StorageChannel channel ) throws ChestNoHandler
private IMEInventoryHandler getHandler( final StorageChannel channel ) throws ChestNoHandler
{
if( !this.isCached )
{
@@ -217,7 +217,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
power += this.cellHandler.cellIdleDrain( is, fluidCell );
}
this.gridProxy.setIdlePowerUsage( power );
this.getProxy().setIdlePowerUsage( power );
this.itemCell = this.wrap( itemCell );
this.fluidCell = this.wrap( fluidCell );
@@ -316,7 +316,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
try
{
gridPowered = this.gridProxy.getEnergy().isNetworkPowered();
gridPowered = this.getProxy().getEnergy().isNetworkPowered();
}
catch( final GridAccessException ignored )
{
@@ -345,7 +345,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
try
{
final IEnergyGrid eg = this.gridProxy.getEnergy();
final IEnergyGrid eg = this.getProxy().getEnergy();
stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE );
if( stash >= amt )
{
@@ -369,11 +369,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
return;
}
final double idleUsage = this.gridProxy.getIdlePowerUsage();
final double idleUsage = this.getProxy().getIdlePowerUsage();
try
{
if( !this.gridProxy.getEnergy().isNetworkPowered() )
if( !this.getProxy().getEnergy().isNetworkPowered() )
{
final double powerUsed = this.extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 )
@@ -384,7 +384,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
}
catch( final GridAccessException e )
{
final double powerUsed = this.extractAEPower( this.gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
final double powerUsed = this.extractAEPower( this.getProxy().getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 )
{
this.recalculateDisplay();
@@ -531,9 +531,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
final IStorageGrid gs = this.gridProxy.getStorage();
final IStorageGrid gs = this.getProxy().getStorage();
Platform.postChanges( gs, removed, added, this.mySrc );
}
catch( final GridAccessException ignored )
@@ -638,7 +638,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
{
if( this.gridProxy.isActive() )
if( this.getProxy().isActive() )
{
try
{
@@ -669,7 +669,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
}
catch( final GridAccessException e )
{
@@ -773,7 +773,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
@Override
public IStorageMonitorable getMonitorable( final EnumFacing side, final BaseActionSource src )
{
if( Platform.canAccess( this.gridProxy, src ) && side != this.getForward() )
if( Platform.canAccess( this.getProxy(), src ) && side != this.getForward() )
{
return this;
}
@@ -868,11 +868,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
private static final long serialVersionUID = 7995805326136526631L;
}
class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
private class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
{
final StorageChannel chan;
private final StorageChannel chan;
public ChestNetNotifier( final StorageChannel chan )
{
@@ -900,9 +899,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
{
try
{
if( TileChest.this.gridProxy.isActive() )
if( TileChest.this.getProxy().isActive() )
{
TileChest.this.gridProxy.getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc );
TileChest.this.getProxy().getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc );
}
}
catch( final GridAccessException e )
@@ -921,8 +920,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
}
}
class ChestMonitorHandler<T extends IAEStack> extends MEMonitorHandler<T>
private class ChestMonitorHandler<T extends IAEStack> extends MEMonitorHandler<T>
{
public ChestMonitorHandler( final IMEInventoryHandler<T> t )
@@ -930,7 +928,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
super( t );
}
public IMEInventoryHandler<T> getInternalHandler()
private IMEInventoryHandler<T> getInternalHandler()
{
final IMEInventoryHandler<T> h = this.getHandler();
if( h instanceof MEInventoryHandler )
@@ -62,23 +62,23 @@ import appeng.util.Platform;
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost
{
final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 10 );
final ICellHandler[] handlersBySlot = new ICellHandler[10];
final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
final BaseActionSource mySrc;
boolean isCached = false;
List<MEInventoryHandler> items = new LinkedList<MEInventoryHandler>();
List<MEInventoryHandler> fluids = new LinkedList<MEInventoryHandler>();
long lastStateChange = 0;
int state = 0;
int priority = 0;
boolean wasActive = false;
private final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 10 );
private final ICellHandler[] handlersBySlot = new ICellHandler[10];
private final DriveWatcher<IAEItemStack>[] invBySlot = new DriveWatcher[10];
private final BaseActionSource mySrc;
private boolean isCached = false;
private List<MEInventoryHandler> items = new LinkedList<MEInventoryHandler>();
private List<MEInventoryHandler> fluids = new LinkedList<MEInventoryHandler>();
private long lastStateChange = 0;
private int state = 0;
private int priority = 0;
private boolean wasActive = false;
public TileDrive()
{
this.mySrc = new MachineSource( this );
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
}
@TileEvent( TileEventType.NETWORK_WRITE )
@@ -93,7 +93,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
this.state &= 0x24924924; // just keep the blinks...
}
if( this.gridProxy.isActive() )
if( this.getProxy().isActive() )
{
this.state |= 0x80000000;
}
@@ -160,7 +160,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
return ( this.state & 0x80000000 ) == 0x80000000;
}
return this.gridProxy.isActive();
return this.getProxy().isActive();
}
@Override
@@ -206,7 +206,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
private void recalculateDisplay()
{
final boolean currentActive = this.gridProxy.isActive();
final boolean currentActive = this.getProxy().isActive();
if( currentActive )
{
this.state |= 0x80000000;
@@ -221,7 +221,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
this.wasActive = currentActive;
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
}
catch( final GridAccessException e )
{
@@ -282,9 +282,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
final IStorageGrid gs = this.gridProxy.getStorage();
final IStorageGrid gs = this.getProxy().getStorage();
Platform.postChanges( gs, removed, added, this.mySrc );
}
catch( final GridAccessException ignored )
@@ -300,7 +300,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
return this.sides;
}
public void updateState()
private void updateState()
{
if( !this.isCached )
{
@@ -350,7 +350,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
}
this.gridProxy.setIdlePowerUsage( power );
this.getProxy().setIdlePowerUsage( power );
this.isCached = true;
}
@@ -366,7 +366,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
{
if( this.gridProxy.isActive() )
if( this.getProxy().isActive() )
{
this.updateState();
return (List) ( channel == StorageChannel.ITEMS ? this.items : this.fluids );
@@ -391,7 +391,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
try
{
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
}
catch( final GridAccessException e )
{
@@ -107,7 +107,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
@Reflected
public TileIOPort()
{
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.manager = new ConfigManager( this );
this.manager.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.manager.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY );
@@ -159,11 +159,11 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
{
if( this.hasWork() )
{
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
else
{
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
this.getProxy().getTick().sleepDevice( this.getProxy().getNode() );
}
}
catch( final GridAccessException e )
@@ -182,7 +182,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
}
public boolean getRedstoneState()
private boolean getRedstoneState()
{
if( this.lastRedstoneState == YesNo.UNDECIDED )
{
@@ -235,7 +235,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
this.updateTask();
}
boolean hasWork()
private boolean hasWork()
{
if( this.isEnabled() )
{
@@ -308,13 +308,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
return new TickingRequest( TickRates.IOPort.min, TickRates.IOPort.max, this.hasWork(), false );
return new TickingRequest( TickRates.IOPort.getMin(), TickRates.IOPort.getMax(), this.hasWork(), false );
}
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
{
if( !this.gridProxy.isActive() )
if( !this.getProxy().isActive() )
{
return TickRateModulation.IDLE;
}
@@ -336,9 +336,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
try
{
final IMEInventory<IAEItemStack> itemNet = this.gridProxy.getStorage().getItemInventory();
final IMEInventory<IAEFluidStack> fluidNet = this.gridProxy.getStorage().getFluidInventory();
final IEnergySource energy = this.gridProxy.getEnergy();
final IMEInventory<IAEItemStack> itemNet = this.getProxy().getStorage().getItemInventory();
final IMEInventory<IAEFluidStack> fluidNet = this.getProxy().getStorage().getFluidInventory();
final IEnergySource energy = this.getProxy().getEnergy();
for( int x = 0; x < 6; x++ )
{
final ItemStack is = this.cells.getStackInSlot( x );
@@ -556,10 +556,10 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
/**
* Adds the items in the upgrade slots to the drop list.
*
* @param w world
* @param x x pos of tile entity
* @param y y pos of tile entity
* @param z z pos of tile entity
* @param w world
* @param x x pos of tile entity
* @param y y pos of tile entity
* @param z z pos of tile entity
* @param drops drops of tile entity
*/
@Override
@@ -35,29 +35,29 @@ import appeng.util.Platform;
public class TileSkyChest extends AEBaseInvTile
{
final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
private final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
// server
public int playerOpen;
private int playerOpen;
// client..
public long lastEvent;
public float lidAngle;
private long lastEvent;
private float lidAngle;
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileSkyChest( final ByteBuf data )
{
data.writeBoolean( this.playerOpen > 0 );
data.writeBoolean( this.getPlayerOpen() > 0 );
}
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileSkyChest( final ByteBuf data )
{
final int wasOpen = this.playerOpen;
this.playerOpen = data.readBoolean() ? 1 : 0;
final int wasOpen = this.getPlayerOpen();
this.setPlayerOpen( data.readBoolean() ? 1 : 0 );
if( wasOpen != this.playerOpen )
if( wasOpen != this.getPlayerOpen() )
{
this.lastEvent = System.currentTimeMillis();
this.setLastEvent( System.currentTimeMillis() );
}
return false; // TESR yo!
@@ -83,9 +83,9 @@ public class TileSkyChest extends AEBaseInvTile
return;
}
this.playerOpen++;
this.setPlayerOpen( this.getPlayerOpen() + 1 );
if( this.playerOpen == 1 )
if( this.getPlayerOpen() == 1 )
{
this.getWorld().playSoundEffect( this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, "random.chestopen", 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
this.markForUpdate();
@@ -100,14 +100,14 @@ public class TileSkyChest extends AEBaseInvTile
return;
}
this.playerOpen--;
this.setPlayerOpen( this.getPlayerOpen() - 1 );
if( this.playerOpen < 0 )
if( this.getPlayerOpen() < 0 )
{
this.playerOpen = 0;
this.setPlayerOpen( 0 );
}
if( this.playerOpen == 0 )
if( this.getPlayerOpen() == 0 )
{
this.getWorld().playSoundEffect( this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D, "random.chestclosed", 0.5F, this.getWorld().rand.nextFloat() * 0.1F + 0.9F );
this.markForUpdate();
@@ -125,4 +125,34 @@ public class TileSkyChest extends AEBaseInvTile
{
return this.sides;
}
public float getLidAngle()
{
return this.lidAngle;
}
public void setLidAngle( final float lidAngle )
{
this.lidAngle = lidAngle;
}
public int getPlayerOpen()
{
return this.playerOpen;
}
private void setPlayerOpen( final int playerOpen )
{
this.playerOpen = playerOpen;
}
public long getLastEvent()
{
return this.lastEvent;
}
private void setLastEvent( final long lastEvent )
{
this.lastEvent = lastEvent;
}
}