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
@@ -46,18 +46,18 @@ import appeng.util.IConfigManagerHost;
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost
{
final AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
final ConfigManager manager = new ConfigManager( this );
private final AppEngInternalInventory cell = new AppEngInternalInventory( this, 1 );
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
private final ConfigManager manager = new ConfigManager( this );
IInventory cacheUpgrades = null;
IInventory cacheConfig = null;
private IInventory cacheUpgrades = null;
private IInventory cacheConfig = null;
private boolean locked = false;
public TileCellWorkbench()
{
this.manager.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
this.cell.enableClientEvents = true;
this.cell.setEnableClientEvents( true );
}
public IInventory getCellUpgradeInventory()
+21 -21
View File
@@ -56,19 +56,19 @@ import appeng.util.item.AEItemStack;
public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpdatePlayerListBox
{
final int[] sides = { 0 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
int tickTickTimer = 0;
private final int[] sides = { 0 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
private int tickTickTimer = 0;
int lastUpdate = 0;
boolean requiresUpdate = false;
private int lastUpdate = 0;
private boolean requiresUpdate = false;
public TileCharger()
{
this.gridProxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.gridProxy.setFlags();
this.internalMaxPower = 1500;
this.gridProxy.setIdlePowerUsage( 0 );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.getProxy().setFlags();
this.setInternalMaxPower( 1500 );
this.getProxy().setIdlePowerUsage( 0 );
}
@Override
@@ -124,11 +124,11 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpda
final ItemStack myItem = this.getStackInSlot( 0 );
// charge from the network!
if( this.internalCurrentPower < 1499 )
if( this.getInternalCurrentPower() < 1499 )
{
try
{
this.injectExternalPower( PowerUnits.AE, this.gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
this.injectExternalPower( PowerUnits.AE, this.getProxy().getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.getInternalCurrentPower() ), Actionable.MODULATE, PowerMultiplier.ONE ) );
this.tickTickTimer = 20; // keep ticking...
}
catch( final GridAccessException e )
@@ -144,27 +144,27 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpda
final IMaterials materials = AEApi.instance().definitions().materials();
if( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
if( this.getInternalCurrentPower() > 149 && Platform.isChargeable( myItem ) )
{
final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
{
final double oldPower = this.internalCurrentPower;
final double oldPower = this.getInternalCurrentPower();
final double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
this.internalCurrentPower += adjustment;
if( oldPower > this.internalCurrentPower )
this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment );
if( oldPower > this.getInternalCurrentPower() )
{
this.requiresUpdate = true;
}
this.tickTickTimer = 20; // keep ticking...
}
}
else if( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
else if( this.getInternalCurrentPower() > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
{
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
{
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
for( final ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
{
@@ -178,7 +178,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpda
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
{
super.setOrientation( inForward, inUp );
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
this.setPowerSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
}
@@ -191,7 +191,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpda
@Override
public boolean canTurn()
{
return this.internalCurrentPower < this.internalMaxPower;
return this.getInternalCurrentPower() < this.getInternalMaxPower();
}
@Override
@@ -200,13 +200,13 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IUpda
this.injectExternalPower( PowerUnits.AE, 150 );
final ItemStack myItem = this.getStackInSlot( 0 );
if( this.internalCurrentPower > 1499 )
if( this.getInternalCurrentPower() > 1499 )
{
final IMaterials materials = AEApi.instance().definitions().materials();
if( materials.certusQuartzCrystal().isSameAs( myItem ) )
{
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
for( final ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
{
@@ -48,11 +48,11 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
{
private static final FluidTankInfo[] EMPTY = { new FluidTankInfo( null, 10 ) };
final int[] sides = { 0, 1 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 3 );
final ConfigManager cm = new ConfigManager( this );
private final int[] sides = { 0, 1 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 3 );
private final ConfigManager cm = new ConfigManager( this );
public double storedPower = 0;
private double storedPower = 0;
public TileCondenser()
{
@@ -63,14 +63,14 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
public void writeToNBT_TileCondenser( final NBTTagCompound data )
{
this.cm.writeToNBT( data );
data.setDouble( "storedPower", this.storedPower );
data.setDouble( "storedPower", this.getStoredPower() );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileCondenser( final NBTTagCompound data )
{
this.cm.readFromNBT( data );
this.storedPower = data.getDouble( "storedPower" );
this.setStoredPower( data.getDouble( "storedPower" ) );
}
public double getStorage()
@@ -92,16 +92,16 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
public void addPower( final double rawPower )
{
this.storedPower += rawPower;
this.storedPower = Math.max( 0.0, Math.min( this.getStorage(), this.storedPower ) );
this.setStoredPower( this.getStoredPower() + rawPower );
this.setStoredPower( Math.max( 0.0, Math.min( this.getStorage(), this.getStoredPower() ) ) );
final double requiredPower = this.getRequiredPower();
final ItemStack output = this.getOutput();
while( requiredPower <= this.storedPower && output != null && requiredPower > 0 )
while( requiredPower <= this.getStoredPower() && output != null && requiredPower > 0 )
{
if( this.canAddOutput( output ) )
{
this.storedPower -= requiredPower;
this.setStoredPower( this.getStoredPower() - requiredPower );
this.addOutput( output );
}
else
@@ -277,4 +277,14 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
{
return this.cm;
}
public double getStoredPower()
{
return this.storedPower;
}
private void setStoredPower( final double storedPower )
{
this.storedPower = storedPower;
}
}
@@ -81,32 +81,32 @@ import com.google.common.collect.Lists;
public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost
{
public final int maxProcessingTime = 100;
final int[] top = { 0 };
final int[] bottom = { 1 };
final int[] sides = { 2, 3 };
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 4 );
private final int maxProcessingTime = 100;
private final int[] top = { 0 };
private final int[] bottom = { 1 };
private final int[] sides = { 2, 3 };
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 4 );
private final IConfigManager settings;
private final UpgradeInventory upgrades;
public int processingTime = 0;
private int processingTime = 0;
// cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the normal routine.
public boolean smash;
public int finalStep;
public long clientStart;
private boolean smash;
private int finalStep;
private long clientStart;
@Reflected
public TileInscriber()
{
this.gridProxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.internalMaxPower = 1500;
this.gridProxy.setIdlePowerUsage( 0 );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.setInternalMaxPower( 1500 );
this.getProxy().setIdlePowerUsage( 0 );
this.settings = new ConfigManager( this );
final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber();
this.upgrades = new DefinitionUpgradeInventory( inscriberDefinition, this, this.getUpgradeSlots() );
}
protected int getUpgradeSlots()
private int getUpgradeSlots()
{
return 3;
}
@@ -138,13 +138,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
final int slot = data.readByte();
final boolean oldSmash = this.smash;
final boolean oldSmash = this.isSmash();
final boolean newSmash = ( slot & 64 ) == 64;
if( oldSmash != newSmash && newSmash )
{
this.smash = true;
this.clientStart = System.currentTimeMillis();
this.setSmash( true );
this.setClientStart( System.currentTimeMillis() );
}
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
@@ -165,7 +165,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileInscriber( final ByteBuf data ) throws IOException
{
int slot = this.smash ? 64 : 0;
int slot = this.isSmash() ? 64 : 0;
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
{
@@ -190,7 +190,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
{
super.setOrientation( inForward, inUp );
this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
this.setPowerSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) );
}
@@ -233,7 +233,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
if( this.smash )
if( this.isSmash() )
{
return false;
}
@@ -266,15 +266,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
if( slot != 3 )
{
this.processingTime = 0;
this.setProcessingTime( 0 );
}
if( !this.smash )
if( !this.isSmash() )
{
this.markForUpdate();
}
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
}
catch( final GridAccessException e )
@@ -286,7 +286,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Override
public boolean canExtractItem( final int slotIndex, final ItemStack extractedItem, final EnumFacing side )
{
if( this.smash )
if( this.isSmash() )
{
return false;
}
@@ -313,7 +313,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
return new TickingRequest( TickRates.Inscriber.min, TickRates.Inscriber.max, !this.hasWork(), false );
return new TickingRequest( TickRates.Inscriber.getMin(), TickRates.Inscriber.getMax(), !this.hasWork(), false );
}
private boolean hasWork()
@@ -323,8 +323,8 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
return true;
}
this.processingTime = 0;
return this.smash;
this.setProcessingTime( 0 );
return this.isSmash();
}
@Nullable
@@ -402,10 +402,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateA, recipe.getTopOptional().orNull() ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orNull() ) );
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orNull() ) );
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateB, recipe.getTopOptional().orNull() ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orNull() ) );
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orNull() ) );
if( matchA || matchB )
{
@@ -424,7 +424,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
{
if( this.smash )
if( this.isSmash() )
{
this.finalStep++;
if( this.finalStep == 8 )
@@ -437,7 +437,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
if( ad.addItems( outputCopy ) == null )
{
this.processingTime = 0;
this.setProcessingTime( 0 );
if( out.getProcessType() == InscriberProcessType.Press )
{
this.setInventorySlotContents( 0, null );
@@ -452,7 +452,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
else if( this.finalStep == 16 )
{
this.finalStep = 0;
this.smash = false;
this.setSmash( false );
this.markForUpdate();
}
}
@@ -460,7 +460,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
try
{
final IEnergyGrid eg = this.gridProxy.getEnergy();
final IEnergyGrid eg = this.getProxy().getEnergy();
IEnergySource src = this;
// Base 1, increase by 1 for each card
@@ -479,13 +479,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG );
if( this.processingTime == 0 )
if( this.getProcessingTime() == 0 )
{
this.processingTime += speedFactor;
this.setProcessingTime( this.getProcessingTime() + speedFactor );
}
else
{
this.processingTime += ticksSinceLastCall * speedFactor;
this.setProcessingTime( this.getProcessingTime() + ticksSinceLastCall * speedFactor );
}
}
}
@@ -494,9 +494,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
// :P
}
if( this.processingTime > this.maxProcessingTime )
if( this.getProcessingTime() > this.getMaxProcessingTime() )
{
this.processingTime = this.maxProcessingTime;
this.setProcessingTime( this.getMaxProcessingTime() );
final IInscriberRecipe out = this.getTask();
if( out != null )
{
@@ -504,7 +504,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, 3, 1, true ), EnumFacing.UP );
if( ad.simulateAdd( outputCopy ) == null )
{
this.smash = true;
this.setSmash( true );
this.finalStep = 0;
this.markForUpdate();
}
@@ -547,4 +547,39 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
}
public long getClientStart()
{
return this.clientStart;
}
private void setClientStart( final long clientStart )
{
this.clientStart = clientStart;
}
public boolean isSmash()
{
return this.smash;
}
public void setSmash( final boolean smash )
{
this.smash = smash;
}
public int getMaxProcessingTime()
{
return this.maxProcessingTime;
}
public int getProcessingTime()
{
return this.processingTime;
}
private void setProcessingTime( final int processingTime )
{
this.processingTime = processingTime;
}
}
@@ -68,8 +68,8 @@ import com.google.common.collect.ImmutableSet;
public class TileInterface extends AENetworkInvTile implements IGridTickable, ITileStorageMonitorable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, IPriorityHost
{
final DualityInterface duality = new DualityInterface( this.gridProxy, this );
AEPartLocation pointAt = AEPartLocation.INTERNAL;
private final DualityInterface duality = new DualityInterface( this.getProxy(), this );
private AEPartLocation pointAt = AEPartLocation.INTERNAL;
@MENetworkEventSubscribe
public void stateChange( final MENetworkChannelsChanged c )
@@ -123,10 +123,10 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
private void configureNodeSides()
{
if ( this.pointAt == AEPartLocation.INTERNAL )
this.gridProxy.setValidSides( EnumSet.allOf(EnumFacing.class) );
if( this.pointAt == AEPartLocation.INTERNAL )
this.getProxy().setValidSides( EnumSet.allOf( EnumFacing.class ) );
else
this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.pointAt.getFacing() ) ) );
this.getProxy().setValidSides( EnumSet.complementOf( EnumSet.of( this.pointAt.getFacing() ) ) );
}
@Override
@@ -154,6 +154,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
public void onReady()
{
this.configureNodeSides();
super.onReady();
this.duality.initialize();
}
@@ -29,8 +29,8 @@ import appeng.util.Platform;
public class TileLightDetector extends AEBaseTile implements IUpdatePlayerListBox
{
int lastCheck = 30;
int lastLight = 0;
private int lastCheck = 30;
private int lastLight = 0;
public boolean isReady()
{
@@ -47,10 +47,10 @@ import com.google.common.collect.ImmutableList;
public class TilePaint extends AEBaseTile
{
static final int LIGHT_PER_DOT = 12;
private static final int LIGHT_PER_DOT = 12;
int isLit = 0;
List<Splotch> dots = null;
private int isLit = 0;
private List<Splotch> dots = null;
@Override
public boolean canBeRotated()
@@ -69,7 +69,7 @@ public class TilePaint extends AEBaseTile
}
}
void writeBuffer( final ByteBuf out )
private void writeBuffer( final ByteBuf out )
{
if( this.dots == null )
{
@@ -94,7 +94,7 @@ public class TilePaint extends AEBaseTile
}
}
void readBuffer( final ByteBuf in )
private void readBuffer( final ByteBuf in )
{
final byte howMany = in.readByte();
@@ -114,7 +114,7 @@ public class TilePaint extends AEBaseTile
this.isLit = 0;
for( final Splotch s : this.dots )
{
if( s.lumen )
if( s.isLumen() )
{
this.isLit += LIGHT_PER_DOT;
}
@@ -180,7 +180,7 @@ public class TilePaint extends AEBaseTile
while( i.hasNext() )
{
final Splotch s = i.next();
if( s.side == side )
if( s.getSide() == side )
{
i.remove();
}
@@ -195,7 +195,7 @@ public class TilePaint extends AEBaseTile
this.isLit = 0;
for( final Splotch s : this.dots )
{
if( s.lumen )
if( s.isLumen() )
{
this.isLit += LIGHT_PER_DOT;
}
@@ -40,13 +40,13 @@ import appeng.util.Platform;
public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState, ICrystalGrowthAccelerator
{
public boolean hasPower = false;
private boolean hasPower = false;
public TileQuartzGrowthAccelerator()
{
this.gridProxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.gridProxy.setFlags();
this.gridProxy.setIdlePowerUsage( 8 );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
this.getProxy().setFlags();
this.getProxy().setIdlePowerUsage( 8 );
}
@MENetworkEventSubscribe
@@ -64,9 +64,9 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileQuartzGrowthAccelerator( final ByteBuf data )
{
final boolean hadPower = this.hasPower;
this.hasPower = data.readBoolean();
return this.hasPower != hadPower;
final boolean hadPower = this.isPowered();
this.setPowered( data.readBoolean() );
return this.isPowered() != hadPower;
}
@TileEvent( TileEventType.NETWORK_WRITE )
@@ -74,7 +74,7 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
{
try
{
data.writeBoolean( this.gridProxy.getEnergy().isNetworkPowered() );
data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() );
}
catch( final GridAccessException e )
{
@@ -86,7 +86,7 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
{
super.setOrientation( inForward, inUp );
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
this.getProxy().setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
}
@Override
@@ -96,7 +96,7 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
{
try
{
return this.gridProxy.getEnergy().isNetworkPowered();
return this.getProxy().getEnergy().isNetworkPowered();
}
catch( final GridAccessException e )
{
@@ -112,4 +112,9 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
{
return this.isPowered();
}
private void setPowered( final boolean hasPower )
{
this.hasPower = hasPower;
}
}
@@ -83,18 +83,18 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
{
private static int difference = 0;
public final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
private final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
private final IConfigManager cm = new ConfigManager( this );
private final SecurityInventory inventory = new SecurityInventory( this );
private final MEMonitorHandler<IAEItemStack> securityMonitor = new MEMonitorHandler<IAEItemStack>( this.inventory );
public long securityKey;
AEColor paintedColor = AEColor.Transparent;
private long securityKey;
private AEColor paintedColor = AEColor.Transparent;
private boolean isActive = false;
public TileSecurity()
{
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.gridProxy.setIdlePowerUsage( 2.0 );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setIdlePowerUsage( 2.0 );
difference++;
this.securityKey = System.currentTimeMillis() * 10 + difference;
@@ -120,12 +120,12 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
final BlockPos pos,
final List<ItemStack> drops )
{
if( !this.configSlot.isEmpty() )
if( !this.getConfigSlot().isEmpty() )
{
drops.add( this.configSlot.getStackInSlot( 0 ) );
drops.add( this.getConfigSlot().getStackInSlot( 0 ) );
}
for( final IAEItemStack ais : this.inventory.storedItems )
for( final IAEItemStack ais : this.inventory.getStoredItems() )
{
drops.add( ais.getItemStack() );
}
@@ -151,7 +151,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileSecurity( final ByteBuf data )
{
data.writeBoolean( this.gridProxy.isActive() );
data.writeBoolean( this.getProxy().isActive() );
data.writeByte( this.paintedColor.ordinal() );
}
@@ -162,12 +162,12 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
data.setLong( "securityKey", this.securityKey );
this.configSlot.writeToNBT( data, "config" );
this.getConfigSlot().writeToNBT( data, "config" );
final NBTTagCompound storedItems = new NBTTagCompound();
int offset = 0;
for( final IAEItemStack ais : this.inventory.storedItems )
for( final IAEItemStack ais : this.inventory.getStoredItems() )
{
final NBTTagCompound it = new NBTTagCompound();
ais.getItemStack().writeToNBT( it );
@@ -188,7 +188,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
}
this.securityKey = data.getLong( "securityKey" );
this.configSlot.readFromNBT( data, "config" );
this.getConfigSlot().readFromNBT( data, "config" );
final NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
for( final Object key : storedItems.getKeySet() )
@@ -196,7 +196,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
final NBTBase obj = storedItems.getTag( (String) key );
if( obj instanceof NBTTagCompound )
{
this.inventory.storedItems.add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
this.inventory.getStoredItems().add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
}
}
}
@@ -206,7 +206,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
try
{
this.saveChanges();
this.gridProxy.getGrid().postEvent( new MENetworkSecurityChange() );
this.getProxy().getGrid().postEvent( new MENetworkSecurityChange() );
}
catch( final GridAccessException e )
{
@@ -290,7 +290,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
public boolean isPowered()
{
return this.gridProxy.isActive();
return this.getProxy().isActive();
}
@Override
@@ -317,7 +317,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
final IPlayerRegistry pr = AEApi.instance().registries().players();
// read permissions
for( final IAEItemStack ais : this.inventory.storedItems )
for( final IAEItemStack ais : this.inventory.getStoredItems() )
{
final ItemStack is = ais.getItemStack();
final Item i = is.getItem();
@@ -329,19 +329,19 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
}
// make sure thea admin is Boss.
playerPerms.put( this.gridProxy.getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
playerPerms.put( this.getProxy().getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
}
@Override
public boolean isSecurityEnabled()
{
return this.isActive && this.gridProxy.isActive();
return this.isActive && this.getProxy().isActive();
}
@Override
public int getOwner()
{
return this.gridProxy.getNode().getPlayerID();
return this.getProxy().getNode().getPlayerID();
}
@Override
@@ -363,4 +363,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
this.markForUpdate();
return true;
}
public AppEngInternalInventory getConfigSlot()
{
return this.configSlot;
}
}
@@ -57,17 +57,17 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
private static final int MIN_BURN_SPEED = 20;
private final IInventory inv = new AppEngInternalInventory( this, 1 );
public int burnSpeed = 100;
public double burnTime = 0;
public double maxBurnTime = 0;
private int burnSpeed = 100;
private double burnTime = 0;
private double maxBurnTime = 0;
// client side..
public boolean isOn;
public TileVibrationChamber()
{
this.gridProxy.setIdlePowerUsage( 0 );
this.gridProxy.setFlags();
this.getProxy().setIdlePowerUsage( 0 );
this.getProxy().setFlags();
}
@Override
@@ -91,23 +91,23 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToNetwork( final ByteBuf data )
{
data.writeBoolean( this.burnTime > 0 );
data.writeBoolean( this.getBurnTime() > 0 );
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TileVibrationChamber( final NBTTagCompound data )
{
data.setDouble( "burnTime", this.burnTime );
data.setDouble( "maxBurnTime", this.maxBurnTime );
data.setInteger( "burnSpeed", this.burnSpeed );
data.setDouble( "burnTime", this.getBurnTime() );
data.setDouble( "maxBurnTime", this.getMaxBurnTime() );
data.setInteger( "burnSpeed", this.getBurnSpeed() );
}
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileVibrationChamber( final NBTTagCompound data )
{
this.burnTime = data.getDouble( "burnTime" );
this.maxBurnTime = data.getDouble( "maxBurnTime" );
this.burnSpeed = data.getInteger( "burnSpeed" );
this.setBurnTime( data.getDouble( "burnTime" ) );
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
this.setBurnSpeed( data.getInteger( "burnSpeed" ) );
}
@Override
@@ -125,13 +125,13 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
@Override
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
{
if( this.burnTime <= 0 )
if( this.getBurnTime() <= 0 )
{
if( this.canEatFuel() )
{
try
{
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
catch( final GridAccessException e )
{
@@ -176,44 +176,44 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
if( this.burnTime <= 0 )
if( this.getBurnTime() <= 0 )
{
this.eatFuel();
}
return new TickingRequest( TickRates.VibrationChamber.min, TickRates.VibrationChamber.max, this.burnTime <= 0, false );
return new TickingRequest( TickRates.VibrationChamber.getMin(), TickRates.VibrationChamber.getMax(), this.getBurnTime() <= 0, false );
}
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
{
if( this.burnTime <= 0 )
if( this.getBurnTime() <= 0 )
{
this.eatFuel();
if( this.burnTime > 0 )
if( this.getBurnTime() > 0 )
{
return TickRateModulation.URGENT;
}
this.burnSpeed = 100;
this.setBurnSpeed( 100 );
return TickRateModulation.SLEEP;
}
this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
final double dilation = this.burnSpeed / DILATION_SCALING;
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
final double dilation = this.getBurnSpeed() / DILATION_SCALING;
double timePassed = ticksSinceLastCall * dilation;
this.burnTime -= timePassed;
if( this.burnTime < 0 )
this.setBurnTime( this.getBurnTime() - timePassed );
if( this.getBurnTime() < 0 )
{
timePassed += this.burnTime;
this.burnTime = 0;
timePassed += this.getBurnTime();
this.setBurnTime( 0 );
}
try
{
final IEnergyGrid grid = this.gridProxy.getEnergy();
final IEnergyGrid grid = this.getProxy().getEnergy();
final double newPower = timePassed * POWER_PER_TICK;
final double overFlow = grid.injectPower( newPower, Actionable.SIMULATE );
@@ -222,20 +222,20 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
if( overFlow > 0 )
{
this.burnSpeed -= ticksSinceLastCall;
this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall );
}
else
{
this.burnSpeed += ticksSinceLastCall;
this.setBurnSpeed( this.getBurnSpeed() + ticksSinceLastCall );
}
this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
}
catch( final GridAccessException e )
{
this.burnSpeed -= ticksSinceLastCall;
this.burnSpeed = Math.max( MIN_BURN_SPEED, Math.min( this.burnSpeed, MAX_BURN_SPEED ) );
this.setBurnSpeed( this.getBurnSpeed() - ticksSinceLastCall );
this.setBurnSpeed( Math.max( MIN_BURN_SPEED, Math.min( this.getBurnSpeed(), MAX_BURN_SPEED ) ) );
return TickRateModulation.SLOWER;
}
}
@@ -248,8 +248,8 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
if( newBurnTime > 0 && is.stackSize > 0 )
{
this.burnTime += newBurnTime;
this.maxBurnTime = this.burnTime;
this.setBurnTime( this.getBurnTime() + newBurnTime );
this.setMaxBurnTime( this.getBurnTime() );
is.stackSize--;
if( is.stackSize <= 0 )
{
@@ -271,11 +271,11 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
}
if( this.burnTime > 0 )
if( this.getBurnTime() > 0 )
{
try
{
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
catch( final GridAccessException e )
{
@@ -284,9 +284,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
// state change
if( ( !this.isOn && this.burnTime > 0 ) || ( this.isOn && this.burnTime <= 0 ) )
if( ( !this.isOn && this.getBurnTime() > 0 ) || ( this.isOn && this.getBurnTime() <= 0 ) )
{
this.isOn = this.burnTime > 0;
this.isOn = this.getBurnTime() > 0;
this.markForUpdate();
if ( this.hasWorldObj() )
@@ -295,4 +295,34 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
}
}
public int getBurnSpeed()
{
return this.burnSpeed;
}
private void setBurnSpeed( final int burnSpeed )
{
this.burnSpeed = burnSpeed;
}
public double getMaxBurnTime()
{
return this.maxBurnTime;
}
private void setMaxBurnTime( final double maxBurnTime )
{
this.maxBurnTime = maxBurnTime;
}
public double getBurnTime()
{
return this.burnTime;
}
private void setBurnTime( final double burnTime )
{
this.burnTime = burnTime;
}
}