Changed access to use this qualifier
This commit is contained in:
@@ -121,23 +121,23 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
private void recalculateDisplay()
|
||||
{
|
||||
int oldState = state;
|
||||
int oldState = this.state;
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( isPowered() )
|
||||
state |= 0x40;
|
||||
if ( this.isPowered() )
|
||||
this.state |= 0x40;
|
||||
else
|
||||
state &= ~0x40;
|
||||
this.state &= ~0x40;
|
||||
|
||||
boolean currentActive = gridProxy.isActive();
|
||||
if ( wasActive != currentActive )
|
||||
boolean currentActive = this.gridProxy.isActive();
|
||||
if ( this.wasActive != currentActive )
|
||||
{
|
||||
wasActive = currentActive;
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -145,8 +145,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
}
|
||||
}
|
||||
|
||||
if ( oldState != state )
|
||||
markForUpdate();
|
||||
if ( oldState != this.state )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +156,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
{
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -164,59 +164,59 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
}
|
||||
}
|
||||
else
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileChest()
|
||||
{
|
||||
if ( worldObj.isRemote )
|
||||
if ( this.worldObj.isRemote )
|
||||
return;
|
||||
|
||||
double idleUsage = gridProxy.getIdlePowerUsage();
|
||||
double idleUsage = this.gridProxy.getIdlePowerUsage();
|
||||
|
||||
try
|
||||
{
|
||||
if ( !gridProxy.getEnergy().isNetworkPowered() )
|
||||
if ( !this.gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
double powerUsed = extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (state & 0x40) > 0 )
|
||||
recalculateDisplay();
|
||||
double powerUsed = this.extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (this.state & 0x40) > 0 )
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
double powerUsed = extractAEPower( gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (state & 0x40) > 0 )
|
||||
recalculateDisplay();
|
||||
double powerUsed = this.extractAEPower( this.gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (this.state & 0x40) > 0 )
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
if ( inv.getStackInSlot( 0 ) != null )
|
||||
if ( this.inv.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
tryToStoreContents();
|
||||
this.tryToStoreContents();
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileChest(ByteBuf data)
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
if ( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
this.state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( isPowered() )
|
||||
state |= 0x40;
|
||||
if ( this.isPowered() )
|
||||
this.state |= 0x40;
|
||||
else
|
||||
state &= ~0x40;
|
||||
this.state &= ~0x40;
|
||||
|
||||
data.writeByte( state );
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
data.writeByte( this.state );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
ItemStack is = inv.getStackInSlot( 1 );
|
||||
ItemStack is = this.inv.getStackInSlot( 1 );
|
||||
|
||||
if ( is == null )
|
||||
{
|
||||
@@ -231,64 +231,64 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileChest(ByteBuf data)
|
||||
{
|
||||
int oldState = state;
|
||||
ItemStack oldType = storageType;
|
||||
int oldState = this.state;
|
||||
ItemStack oldType = this.storageType;
|
||||
|
||||
state = data.readByte();
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
this.state = data.readByte();
|
||||
AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
int item = data.readInt();
|
||||
|
||||
if ( item == 0 )
|
||||
storageType = null;
|
||||
this.storageType = null;
|
||||
else
|
||||
storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET );
|
||||
this.storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET );
|
||||
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
this.lastStateChange = this.worldObj.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != paintedColor || (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || !Platform.isSameItemPrecise( oldType, storageType );
|
||||
return oldPaintedColor != this.paintedColor || (this.state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || !Platform.isSameItemPrecise( oldType, this.storageType );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileChest(NBTTagCompound data)
|
||||
{
|
||||
config.readFromNBT( data );
|
||||
priority = data.getInteger( "priority" );
|
||||
this.config.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileChest(NBTTagCompound data)
|
||||
{
|
||||
config.writeToNBT( data );
|
||||
data.setInteger( "priority", priority );
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
this.config.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelRender(MENetworkChannelsChanged c)
|
||||
{
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public TileChest()
|
||||
{
|
||||
internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
config.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
config.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
this.internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
|
||||
this.gridProxy.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 );
|
||||
|
||||
internalPublicPowerStorage = true;
|
||||
internalPowerFlow = AccessRestriction.WRITE;
|
||||
this.internalPublicPowerStorage = true;
|
||||
this.internalPowerFlow = AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
boolean isCached = false;
|
||||
@@ -300,13 +300,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public IMEMonitor getItemInventory()
|
||||
{
|
||||
return itemCell;
|
||||
return this.itemCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor getFluidInventory()
|
||||
{
|
||||
return fluidCell;
|
||||
return this.fluidCell;
|
||||
}
|
||||
|
||||
class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
|
||||
@@ -322,12 +322,12 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<T> monitor, Iterable<T> change, BaseActionSource source)
|
||||
{
|
||||
if ( source == mySrc || (source instanceof PlayerSource && ((PlayerSource) source).via == TileChest.this) )
|
||||
if ( source == TileChest.this.mySrc || (source instanceof PlayerSource && ((PlayerSource) source).via == TileChest.this) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( gridProxy.isActive() )
|
||||
gridProxy.getStorage().postAlterationOfStoredItems( chan, change, mySrc );
|
||||
if ( TileChest.this.gridProxy.isActive() )
|
||||
TileChest.this.gridProxy.getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -335,16 +335,16 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
}
|
||||
}
|
||||
|
||||
blinkCell( 0 );
|
||||
TileChest.this.blinkCell( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return verificationToken == itemCell;
|
||||
if ( chan == StorageChannel.FLUIDS )
|
||||
return verificationToken == fluidCell;
|
||||
if ( this.chan == StorageChannel.ITEMS )
|
||||
return verificationToken == TileChest.this.itemCell;
|
||||
if ( this.chan == StorageChannel.FLUIDS )
|
||||
return verificationToken == TileChest.this.fluidCell;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
public IMEInventoryHandler<T> getInternalHandler()
|
||||
{
|
||||
IMEInventoryHandler<T> h = getHandler();
|
||||
IMEInventoryHandler<T> h = this.getHandler();
|
||||
if ( h instanceof MEInventoryHandler )
|
||||
return (IMEInventoryHandler<T>) ((MEInventoryHandler) h).getInternal();
|
||||
return this.getHandler();
|
||||
@@ -374,11 +374,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
private boolean securityCheck(EntityPlayer player, SecurityPermissions requiredPermission)
|
||||
{
|
||||
if ( getTile() instanceof IActionHost && requiredPermission != null )
|
||||
if ( TileChest.this.getTile() instanceof IActionHost && requiredPermission != null )
|
||||
{
|
||||
boolean requirePower = false;
|
||||
|
||||
IGridNode gn = ((IActionHost) getTile()).getActionableNode();
|
||||
IGridNode gn = ((IActionHost) TileChest.this.getTile()).getActionableNode();
|
||||
if ( gn != null )
|
||||
{
|
||||
IGrid g = gn.getGrid();
|
||||
@@ -407,7 +407,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public T injectItems(T input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( src.isPlayer() && !securityCheck(((PlayerSource) src).player, SecurityPermissions.INJECT) )
|
||||
if ( src.isPlayer() && !this.securityCheck(((PlayerSource) src).player, SecurityPermissions.INJECT) )
|
||||
return input;
|
||||
return super.injectItems(input, mode, src);
|
||||
}
|
||||
@@ -415,7 +415,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public T extractItems(T request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( src.isPlayer() && !securityCheck(((PlayerSource) src).player, SecurityPermissions.EXTRACT) )
|
||||
if ( src.isPlayer() && !this.securityCheck(((PlayerSource) src).player, SecurityPermissions.EXTRACT) )
|
||||
return null;
|
||||
return super.extractItems(request, mode, src);
|
||||
}
|
||||
@@ -427,7 +427,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
return null;
|
||||
|
||||
MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() );
|
||||
ih.myPriority = priority;
|
||||
ih.myPriority = this.priority;
|
||||
|
||||
MEMonitorHandler<StackType> g = new ChestMonitorHandler<StackType>( ih );
|
||||
g.addListener( new ChestNetNotifier( h.getChannel() ), g );
|
||||
@@ -437,32 +437,32 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
public IMEInventoryHandler getHandler(StorageChannel channel) throws ChestNoHandler
|
||||
{
|
||||
if ( !isCached )
|
||||
if ( !this.isCached )
|
||||
{
|
||||
itemCell = null;
|
||||
fluidCell = null;
|
||||
this.itemCell = null;
|
||||
this.fluidCell = null;
|
||||
|
||||
ItemStack is = inv.getStackInSlot( 1 );
|
||||
ItemStack is = this.inv.getStackInSlot( 1 );
|
||||
if ( is != null )
|
||||
{
|
||||
isCached = true;
|
||||
cellHandler = AEApi.instance().registries().cell().getHandler( is );
|
||||
if ( cellHandler != null )
|
||||
this.isCached = true;
|
||||
this.cellHandler = AEApi.instance().registries().cell().getHandler( is );
|
||||
if ( this.cellHandler != null )
|
||||
{
|
||||
double power = 1.0;
|
||||
|
||||
IMEInventoryHandler<IAEItemStack> itemCell = cellHandler.getCellInventory( is, this, StorageChannel.ITEMS );
|
||||
IMEInventoryHandler<IAEFluidStack> fluidCell = cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS );
|
||||
IMEInventoryHandler<IAEItemStack> itemCell = this.cellHandler.getCellInventory( is, this, StorageChannel.ITEMS );
|
||||
IMEInventoryHandler<IAEFluidStack> fluidCell = this.cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS );
|
||||
|
||||
if ( itemCell != null )
|
||||
power += cellHandler.cellIdleDrain( is, itemCell );
|
||||
power += this.cellHandler.cellIdleDrain( is, itemCell );
|
||||
else if ( fluidCell != null )
|
||||
power += cellHandler.cellIdleDrain( is, fluidCell );
|
||||
power += this.cellHandler.cellIdleDrain( is, fluidCell );
|
||||
|
||||
gridProxy.setIdlePowerUsage( power );
|
||||
this.gridProxy.setIdlePowerUsage( power );
|
||||
|
||||
this.itemCell = wrap( itemCell );
|
||||
this.fluidCell = wrap( fluidCell );
|
||||
this.itemCell = this.wrap( itemCell );
|
||||
this.fluidCell = this.wrap( fluidCell );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,13 +470,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
switch (channel)
|
||||
{
|
||||
case FLUIDS:
|
||||
if ( fluidCell == null )
|
||||
if ( this.fluidCell == null )
|
||||
throw noHandler;
|
||||
return fluidCell;
|
||||
return this.fluidCell;
|
||||
case ITEMS:
|
||||
if ( itemCell == null )
|
||||
if ( this.itemCell == null )
|
||||
throw noHandler;
|
||||
return itemCell;
|
||||
return this.itemCell;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return inv;
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -494,16 +494,16 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
{
|
||||
if ( slot == 1 )
|
||||
{
|
||||
itemCell = null;
|
||||
fluidCell = null;
|
||||
isCached = false; // recalculate the storage cell.
|
||||
this.itemCell = null;
|
||||
this.fluidCell = null;
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
|
||||
IStorageGrid gs = gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added, mySrc );
|
||||
IStorageGrid gs = this.gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
catch (GridAccessException ignored)
|
||||
{
|
||||
@@ -511,10 +511,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
}
|
||||
|
||||
// update the neighbors
|
||||
if ( worldObj != null )
|
||||
if ( this.worldObj != null )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( worldObj, xCoord, yCoord, zCoord );
|
||||
markForUpdate();
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -522,24 +522,24 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
inv.setInventorySlotContents( i, itemstack );
|
||||
tryToStoreContents();
|
||||
this.inv.setInventorySlotContents( i, itemstack );
|
||||
this.tryToStoreContents();
|
||||
}
|
||||
|
||||
private void tryToStoreContents()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( getStackInSlot( 0 ) != null )
|
||||
if ( this.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
IMEInventory<IAEItemStack> cell = getHandler( StorageChannel.ITEMS );
|
||||
IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
|
||||
|
||||
IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ), mySrc );
|
||||
IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), this.mySrc );
|
||||
|
||||
if ( returns == null )
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
this.inv.setInventorySlotContents( 0, null );
|
||||
else
|
||||
inv.setInventorySlotContents( 0, returns.getItemStack() );
|
||||
this.inv.setInventorySlotContents( 0, returns.getItemStack() );
|
||||
}
|
||||
}
|
||||
catch (ChestNoHandler ignored)
|
||||
@@ -567,8 +567,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
{
|
||||
try
|
||||
{
|
||||
IMEInventory<IAEItemStack> cell = getHandler( StorageChannel.ITEMS );
|
||||
IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( inv.getStackInSlot( 0 ) ), Actionable.SIMULATE, mySrc );
|
||||
IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
|
||||
IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), Actionable.SIMULATE, this.mySrc );
|
||||
return returns == null || returns.getStackSize() != itemstack.stackSize;
|
||||
}
|
||||
catch (ChestNoHandler ignored)
|
||||
@@ -584,11 +584,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
if ( ForgeDirection.SOUTH == side )
|
||||
return front;
|
||||
|
||||
if ( isPowered() )
|
||||
if ( this.isPowered() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( getHandler( StorageChannel.ITEMS ) != null )
|
||||
if ( this.getHandler( StorageChannel.ITEMS ) != null )
|
||||
return sides;
|
||||
}
|
||||
catch (ChestNoHandler e)
|
||||
@@ -602,11 +602,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
||||
{
|
||||
if ( gridProxy.isActive() )
|
||||
if ( this.gridProxy.isActive() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Collections.singletonList( getHandler( channel ) );
|
||||
return Collections.singletonList( this.getHandler( channel ) );
|
||||
}
|
||||
catch (ChestNoHandler e)
|
||||
{
|
||||
@@ -619,7 +619,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return priority;
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -631,40 +631,40 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public void blinkCell(int slot)
|
||||
{
|
||||
long now = worldObj.getTotalWorldTime();
|
||||
if ( now - lastStateChange > 8 )
|
||||
state = 0;
|
||||
lastStateChange = now;
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
this.lastStateChange = now;
|
||||
|
||||
state |= 1 << (slot * 3 + 2);
|
||||
this.state |= 1 << (slot * 3 + 2);
|
||||
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking(int slot)
|
||||
{
|
||||
long now = worldObj.getTotalWorldTime();
|
||||
if ( now - lastStateChange > 8 )
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
return false;
|
||||
|
||||
return ((state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(int slot)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (state >> (slot * 3)) & 3;
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
|
||||
ItemStack cell = inv.getStackInSlot( 1 );
|
||||
ItemStack cell = this.inv.getStackInSlot( 1 );
|
||||
ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );
|
||||
|
||||
if ( ch != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
IMEInventoryHandler handler = getHandler( StorageChannel.ITEMS );
|
||||
IMEInventoryHandler handler = this.getHandler( StorageChannel.ITEMS );
|
||||
if ( handler instanceof ChestMonitorHandler )
|
||||
return ch.getStatusForCell( cell, ((ChestMonitorHandler) handler).getInternalHandler() );
|
||||
}
|
||||
@@ -674,7 +674,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
|
||||
try
|
||||
{
|
||||
IMEInventoryHandler handler = getHandler( StorageChannel.FLUIDS );
|
||||
IMEInventoryHandler handler = this.getHandler( StorageChannel.FLUIDS );
|
||||
if ( handler instanceof ChestMonitorHandler )
|
||||
return ch.getStatusForCell( cell, ((ChestMonitorHandler) handler).getInternalHandler() );
|
||||
}
|
||||
@@ -690,15 +690,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
double req = resource.amount / 500.0;
|
||||
double available = extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
double available = this.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
if ( available >= req - 0.01 )
|
||||
{
|
||||
try
|
||||
{
|
||||
IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS );
|
||||
IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
|
||||
|
||||
extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE, mySrc );
|
||||
this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.mySrc );
|
||||
|
||||
if ( results == null )
|
||||
return resource.amount;
|
||||
@@ -729,7 +729,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
{
|
||||
try
|
||||
{
|
||||
IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS );
|
||||
IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
|
||||
return h.canAccept( AEFluidStack.create( new FluidStack( fluid, 1 ) ) );
|
||||
}
|
||||
catch (ChestNoHandler ignored)
|
||||
@@ -749,7 +749,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
{
|
||||
try
|
||||
{
|
||||
IMEInventoryHandler h = getHandler( StorageChannel.FLUIDS );
|
||||
IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS );
|
||||
if ( h.getChannel() == StorageChannel.FLUIDS )
|
||||
return new FluidTankInfo[] { new FluidTankInfo( null, 1 ) }; // eh?
|
||||
}
|
||||
@@ -768,7 +768,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
IEnergyGrid eg;
|
||||
try
|
||||
{
|
||||
eg = gridProxy.getEnergy();
|
||||
eg = this.gridProxy.getEnergy();
|
||||
stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE );
|
||||
if ( stash >= amt )
|
||||
return stash;
|
||||
@@ -786,15 +786,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (state & 0x40) == 0x40;
|
||||
return (this.state & 0x40) == 0x40;
|
||||
|
||||
boolean gridPowered = getAECurrentPower() > 64;
|
||||
boolean gridPowered = this.getAECurrentPower() > 64;
|
||||
|
||||
if ( !gridPowered )
|
||||
{
|
||||
try
|
||||
{
|
||||
gridPowered = gridProxy.getEnergy().isNetworkPowered();
|
||||
gridPowered = this.gridProxy.getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch (GridAccessException ignored)
|
||||
{
|
||||
@@ -807,30 +807,30 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||
{
|
||||
if ( Platform.canAccess( gridProxy, src ) && side != getForward() )
|
||||
if ( Platform.canAccess( this.gridProxy, src ) && side != this.getForward() )
|
||||
return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getStorageType()
|
||||
{
|
||||
if ( isPowered() )
|
||||
return storageType;
|
||||
if ( this.isPowered() )
|
||||
return this.storageType;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
{
|
||||
priority = newValue;
|
||||
this.priority = newValue;
|
||||
|
||||
itemCell = null;
|
||||
fluidCell = null;
|
||||
isCached = false; // recalculate the storage cell.
|
||||
this.itemCell = null;
|
||||
this.fluidCell = null;
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -841,7 +841,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return config;
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -887,24 +887,24 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return paintedColor;
|
||||
return this.paintedColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
{
|
||||
if ( paintedColor == newPaintedColor )
|
||||
if ( this.paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
paintedColor = newPaintedColor;
|
||||
markDirty();
|
||||
markForUpdate();
|
||||
this.paintedColor = newPaintedColor;
|
||||
this.markDirty();
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(IMEInventory cellInventory)
|
||||
{
|
||||
worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
this.worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,18 +78,18 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
{
|
||||
int oldState = 0;
|
||||
|
||||
boolean currentActive = gridProxy.isActive();
|
||||
boolean currentActive = this.gridProxy.isActive();
|
||||
if ( currentActive )
|
||||
state |= 0x80000000;
|
||||
this.state |= 0x80000000;
|
||||
else
|
||||
state &= ~0x80000000;
|
||||
this.state &= ~0x80000000;
|
||||
|
||||
if ( wasActive != currentActive )
|
||||
if ( this.wasActive != currentActive )
|
||||
{
|
||||
wasActive = currentActive;
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -97,69 +97,69 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( oldState != state )
|
||||
markForUpdate();
|
||||
if ( oldState != this.state )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileDrive(ByteBuf data)
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
if ( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
this.state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
if ( gridProxy.isActive() )
|
||||
state |= 0x80000000;
|
||||
if ( this.gridProxy.isActive() )
|
||||
this.state |= 0x80000000;
|
||||
else
|
||||
state &= ~0x80000000;
|
||||
this.state &= ~0x80000000;
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
for (int x = 0; x < this.getCellCount(); x++)
|
||||
this.state |= (this.getCellStatus( x ) << (3 * x));
|
||||
|
||||
data.writeInt( state );
|
||||
data.writeInt( this.state );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileDrive(ByteBuf data)
|
||||
{
|
||||
int oldState = state;
|
||||
state = data.readInt();
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
return (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB);
|
||||
int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
this.lastStateChange = this.worldObj.getTotalWorldTime();
|
||||
return (this.state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB);
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
isCached = false;
|
||||
priority = data.getInteger( "priority" );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "priority", priority );
|
||||
data.setInteger( "priority", this.priority );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelRender(MENetworkChannelsChanged c)
|
||||
{
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
public TileDrive() {
|
||||
mySrc = new MachineSource( this );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.mySrc = new MachineSource( this );
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,108 +177,108 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return inv;
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
updateState();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
if ( isCached )
|
||||
if ( this.isCached )
|
||||
{
|
||||
isCached = false; // recalculate the storage cell.
|
||||
updateState();
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
|
||||
IStorageGrid gs = gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added, mySrc );
|
||||
IStorageGrid gs = this.gridProxy.getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
catch (GridAccessException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
markForUpdate();
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
{
|
||||
return sides;
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
public void updateState()
|
||||
{
|
||||
if ( !isCached )
|
||||
if ( !this.isCached )
|
||||
{
|
||||
items = new LinkedList();
|
||||
fluids = new LinkedList();
|
||||
this.items = new LinkedList();
|
||||
this.fluids = new LinkedList();
|
||||
|
||||
double power = 2.0;
|
||||
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
for (int x = 0; x < this.inv.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( x );
|
||||
invBySlot[x] = null;
|
||||
handlersBySlot[x] = null;
|
||||
ItemStack is = this.inv.getStackInSlot( x );
|
||||
this.invBySlot[x] = null;
|
||||
this.handlersBySlot[x] = null;
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is );
|
||||
this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is );
|
||||
|
||||
if ( handlersBySlot[x] != null )
|
||||
if ( this.handlersBySlot[x] != null )
|
||||
{
|
||||
IMEInventoryHandler cell = handlersBySlot[x].getCellInventory( is, this, StorageChannel.ITEMS );
|
||||
IMEInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.ITEMS );
|
||||
|
||||
if ( cell != null )
|
||||
{
|
||||
power += handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
power += this.handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
|
||||
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, handlersBySlot[x], this );
|
||||
ih.myPriority = priority;
|
||||
invBySlot[x] = ih;
|
||||
items.add( ih );
|
||||
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this );
|
||||
ih.myPriority = this.priority;
|
||||
this.invBySlot[x] = ih;
|
||||
this.items.add( ih );
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = handlersBySlot[x].getCellInventory( is, this, StorageChannel.FLUIDS );
|
||||
cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.FLUIDS );
|
||||
|
||||
if ( cell != null )
|
||||
{
|
||||
power += handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
power += this.handlersBySlot[x].cellIdleDrain( is, cell );
|
||||
|
||||
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, handlersBySlot[x], this );
|
||||
ih.myPriority = priority;
|
||||
invBySlot[x] = ih;
|
||||
fluids.add( ih );
|
||||
DriveWatcher<IAEItemStack> ih = new DriveWatcher( cell, is, this.handlersBySlot[x], this );
|
||||
ih.myPriority = this.priority;
|
||||
this.invBySlot[x] = ih;
|
||||
this.fluids.add( ih );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gridProxy.setIdlePowerUsage( power );
|
||||
this.gridProxy.setIdlePowerUsage( power );
|
||||
|
||||
isCached = true;
|
||||
this.isCached = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel)
|
||||
{
|
||||
if ( gridProxy.isActive() )
|
||||
if ( this.gridProxy.isActive() )
|
||||
{
|
||||
updateState();
|
||||
return (List) (channel == StorageChannel.ITEMS ? items : fluids);
|
||||
this.updateState();
|
||||
return (List) (channel == StorageChannel.ITEMS ? this.items : this.fluids);
|
||||
}
|
||||
return new ArrayList();
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return priority;
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -298,36 +298,36 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Override
|
||||
public void blinkCell(int slot)
|
||||
{
|
||||
long now = worldObj.getTotalWorldTime();
|
||||
if ( now - lastStateChange > 8 )
|
||||
state = 0;
|
||||
lastStateChange = now;
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
this.state = 0;
|
||||
this.lastStateChange = now;
|
||||
|
||||
state |= 1 << (slot * 3 + 2);
|
||||
this.state |= 1 << (slot * 3 + 2);
|
||||
|
||||
recalculateDisplay();
|
||||
this.recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellBlinking(int slot)
|
||||
{
|
||||
long now = worldObj.getTotalWorldTime();
|
||||
if ( now - lastStateChange > 8 )
|
||||
long now = this.worldObj.getTotalWorldTime();
|
||||
if ( now - this.lastStateChange > 8 )
|
||||
return false;
|
||||
|
||||
return ((state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
return ((this.state >> (slot * 3 + 2)) & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus(int slot)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (state >> (slot * 3)) & 3;
|
||||
return (this.state >> (slot * 3)) & 3;
|
||||
|
||||
ItemStack cell = inv.getStackInSlot( 2 );
|
||||
ICellHandler ch = handlersBySlot[slot];
|
||||
ItemStack cell = this.inv.getStackInSlot( 2 );
|
||||
ICellHandler ch = this.handlersBySlot[slot];
|
||||
|
||||
MEInventoryHandler handler = invBySlot[slot];
|
||||
MEInventoryHandler handler = this.invBySlot[slot];
|
||||
if ( handler == null )
|
||||
return 0;
|
||||
|
||||
@@ -350,23 +350,23 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return (state & 0x80000000) == 0x80000000;
|
||||
return (this.state & 0x80000000) == 0x80000000;
|
||||
|
||||
return gridProxy.isActive();
|
||||
return this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
{
|
||||
priority = newValue;
|
||||
markDirty();
|
||||
this.priority = newValue;
|
||||
this.markDirty();
|
||||
|
||||
isCached = false; // recalculate the storage cell.
|
||||
updateState();
|
||||
this.isCached = false; // recalculate the storage cell.
|
||||
this.updateState();
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -383,6 +383,6 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
@Override
|
||||
public void saveChanges(IMEInventory cellInventory)
|
||||
{
|
||||
worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
this.worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,27 +86,27 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileIOPort(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
cells.writeToNBT( data, "cells" );
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", lastRedstoneState.ordinal() );
|
||||
this.cm.writeToNBT( data );
|
||||
this.cells.writeToNBT( data, "cells" );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileIOPort(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
cells.readFromNBT( data, "cells" );
|
||||
upgrades.readFromNBT( data, "upgrades" );
|
||||
this.cm.readFromNBT( data );
|
||||
this.cells.readFromNBT( data, "cells" );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
|
||||
public TileIOPort() {
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
cm.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
cm.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
cm.registerSetting( Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.cm.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.cm.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
this.cm.registerSetting( Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,15 +124,15 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return cells;
|
||||
return this.cells;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
if ( cells == inv )
|
||||
if ( this.cells == inv )
|
||||
{
|
||||
updateTask();
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,10 +140,10 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( hasWork() )
|
||||
gridProxy.getTick().wakeDevice( gridProxy.getNode() );
|
||||
if ( this.hasWork() )
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
else
|
||||
gridProxy.getTick().sleepDevice( gridProxy.getNode() );
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
@@ -153,56 +153,56 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
public void updateRedstoneState()
|
||||
{
|
||||
YesNo currentState = worldObj.isBlockIndirectlyGettingPowered( xCoord, yCoord, zCoord ) ? YesNo.YES : YesNo.NO;
|
||||
if ( lastRedstoneState != currentState )
|
||||
YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO;
|
||||
if ( this.lastRedstoneState != currentState )
|
||||
{
|
||||
lastRedstoneState = currentState;
|
||||
updateTask();
|
||||
this.lastRedstoneState = currentState;
|
||||
this.updateTask();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRedstoneState()
|
||||
{
|
||||
if ( lastRedstoneState == YesNo.UNDECIDED )
|
||||
updateRedstoneState();
|
||||
if ( this.lastRedstoneState == YesNo.UNDECIDED )
|
||||
this.updateRedstoneState();
|
||||
|
||||
return lastRedstoneState == YesNo.YES;
|
||||
return this.lastRedstoneState == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isEnabled()
|
||||
{
|
||||
if ( getInstalledUpgrades( Upgrades.REDSTONE ) == 0 )
|
||||
if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 )
|
||||
return true;
|
||||
|
||||
RedstoneMode rs = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
RedstoneMode rs = (RedstoneMode) this.cm.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
if ( rs == RedstoneMode.HIGH_SIGNAL )
|
||||
return getRedstoneState();
|
||||
return !getRedstoneState();
|
||||
return this.getRedstoneState();
|
||||
return !this.getRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection d)
|
||||
{
|
||||
if ( d == ForgeDirection.UP || d == ForgeDirection.DOWN )
|
||||
return input;
|
||||
return this.input;
|
||||
|
||||
return output;
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return cm;
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
if ( name.equals( "upgrades" ) )
|
||||
return upgrades;
|
||||
return this.upgrades;
|
||||
|
||||
if ( name.equals( "cells" ) )
|
||||
return cells;
|
||||
return this.cells;
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -210,21 +210,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
{
|
||||
return upgrades.getInstalledUpgrades( u );
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
updateTask();
|
||||
this.updateTask();
|
||||
}
|
||||
|
||||
boolean hasWork()
|
||||
{
|
||||
if ( isEnabled() )
|
||||
if ( this.isEnabled() )
|
||||
{
|
||||
for (int x = 0; x < 6; x++)
|
||||
if ( cells.getStackInSlot( x ) != null )
|
||||
if ( this.cells.getStackInSlot( x ) != null )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,18 +234,18 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
{
|
||||
return new TickingRequest( TickRates.IOPort.min, TickRates.IOPort.max, hasWork(), false );
|
||||
return new TickingRequest( TickRates.IOPort.min, TickRates.IOPort.max, this.hasWork(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
if ( !gridProxy.isActive() )
|
||||
if ( !this.gridProxy.isActive() )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
long ItemsToMove = 256;
|
||||
|
||||
switch (getInstalledUpgrades( Upgrades.SPEED ))
|
||||
switch (this.getInstalledUpgrades( Upgrades.SPEED ))
|
||||
{
|
||||
case 1:
|
||||
ItemsToMove *= 2;
|
||||
@@ -260,35 +260,35 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
try
|
||||
{
|
||||
IMEInventory<IAEItemStack> itemNet = gridProxy.getStorage().getItemInventory();
|
||||
IMEInventory<IAEFluidStack> fluidNet = gridProxy.getStorage().getFluidInventory();
|
||||
IEnergySource energy = gridProxy.getEnergy();
|
||||
IMEInventory<IAEItemStack> itemNet = this.gridProxy.getStorage().getItemInventory();
|
||||
IMEInventory<IAEFluidStack> fluidNet = this.gridProxy.getStorage().getFluidInventory();
|
||||
IEnergySource energy = this.gridProxy.getEnergy();
|
||||
for (int x = 0; x < 6; x++)
|
||||
{
|
||||
ItemStack is = cells.getStackInSlot( x );
|
||||
ItemStack is = this.cells.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
{
|
||||
if ( ItemsToMove > 0 )
|
||||
{
|
||||
IMEInventory<IAEItemStack> itemInv = getInv( is, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEFluidStack> fluidInv = getInv( is, StorageChannel.FLUIDS );
|
||||
IMEInventory<IAEItemStack> itemInv = this.getInv( is, StorageChannel.ITEMS );
|
||||
IMEInventory<IAEFluidStack> fluidInv = this.getInv( is, StorageChannel.FLUIDS );
|
||||
|
||||
if ( cm.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
|
||||
if ( this.cm.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
|
||||
{
|
||||
if ( itemInv != null )
|
||||
ItemsToMove = transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS );
|
||||
ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS );
|
||||
if ( fluidInv != null )
|
||||
ItemsToMove = transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS );
|
||||
ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( itemInv != null )
|
||||
ItemsToMove = transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS );
|
||||
ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS );
|
||||
if ( fluidInv != null )
|
||||
ItemsToMove = transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS );
|
||||
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS );
|
||||
}
|
||||
|
||||
if ( ItemsToMove > 0 && shouldMove( itemInv, fluidInv ) && !moveSlot( x ) )
|
||||
if ( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) )
|
||||
return TickRateModulation.IDLE;
|
||||
|
||||
return TickRateModulation.URGENT;
|
||||
@@ -310,14 +310,14 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
private boolean shouldMove(IMEInventory<IAEItemStack> itemInv, IMEInventory<IAEFluidStack> fluidInv)
|
||||
{
|
||||
FullnessMode fm = (FullnessMode) cm.getSetting( Settings.FULLNESS_MODE );
|
||||
FullnessMode fm = (FullnessMode) this.cm.getSetting( Settings.FULLNESS_MODE );
|
||||
|
||||
if ( itemInv != null && fluidInv != null )
|
||||
return matches( fm, itemInv ) && matches( fm, fluidInv );
|
||||
return this.matches( fm, itemInv ) && this.matches( fm, fluidInv );
|
||||
else if ( itemInv != null )
|
||||
return matches( fm, itemInv );
|
||||
return this.matches( fm, itemInv );
|
||||
else if ( fluidInv != null )
|
||||
return matches( fm, fluidInv );
|
||||
return this.matches( fm, fluidInv );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
if ( test != null )
|
||||
{
|
||||
test.setStackSize( 1 );
|
||||
return src.injectItems( test, Actionable.SIMULATE, mySrc ) != null;
|
||||
return src.injectItems( test, Actionable.SIMULATE, this.mySrc ) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -352,17 +352,17 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
private IMEInventory getInv(ItemStack is, StorageChannel chan)
|
||||
{
|
||||
if ( currentCell != is )
|
||||
if ( this.currentCell != is )
|
||||
{
|
||||
currentCell = is;
|
||||
cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.FLUIDS );
|
||||
cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
this.currentCell = is;
|
||||
this.cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.FLUIDS );
|
||||
this.cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
}
|
||||
|
||||
if ( StorageChannel.ITEMS == chan )
|
||||
return cachedItem;
|
||||
return this.cachedItem;
|
||||
|
||||
return cachedFluid;
|
||||
return this.cachedFluid;
|
||||
}
|
||||
|
||||
private long transferContents(IEnergySource energy, IMEInventory src, IMEInventory destination, long itemsToMove, StorageChannel chan)
|
||||
@@ -384,7 +384,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
long totalStackSize = s.getStackSize();
|
||||
if ( totalStackSize > 0 )
|
||||
{
|
||||
IAEStack stack = destination.injectItems( s, Actionable.SIMULATE, mySrc );
|
||||
IAEStack stack = destination.injectItems( s, Actionable.SIMULATE, this.mySrc );
|
||||
|
||||
long possible = 0;
|
||||
if ( stack == null )
|
||||
@@ -397,16 +397,16 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
possible = Math.min( possible, itemsToMove );
|
||||
s.setStackSize( possible );
|
||||
|
||||
IAEStack extracted = src.extractItems( s, Actionable.MODULATE, mySrc );
|
||||
IAEStack extracted = src.extractItems( s, Actionable.MODULATE, this.mySrc );
|
||||
if ( extracted != null )
|
||||
{
|
||||
possible = extracted.getStackSize();
|
||||
IAEStack failed = Platform.poweredInsert( energy, destination, extracted, mySrc );
|
||||
IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc );
|
||||
|
||||
if ( failed != null )
|
||||
{
|
||||
possible -= failed.getStackSize();
|
||||
src.injectItems( failed, Actionable.MODULATE, mySrc );
|
||||
src.injectItems( failed, Actionable.MODULATE, this.mySrc );
|
||||
}
|
||||
|
||||
if ( possible > 0 )
|
||||
@@ -428,12 +428,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
|
||||
private boolean moveSlot(int x)
|
||||
{
|
||||
WrapperInventoryRange wir = new WrapperInventoryRange( this, outputSlots, true );
|
||||
ItemStack result = InventoryAdaptor.getAdaptor( wir, ForgeDirection.UNKNOWN ).addItems( getStackInSlot( x ) );
|
||||
WrapperInventoryRange wir = new WrapperInventoryRange( this, this.outputSlots, true );
|
||||
ItemStack result = InventoryAdaptor.getAdaptor( wir, ForgeDirection.UNKNOWN ).addItems( this.getStackInSlot( x ) );
|
||||
|
||||
if ( result == null )
|
||||
{
|
||||
setInventorySlotContents( x, null );
|
||||
this.setInventorySlotContents( x, null );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,17 @@ public class TileSkyChest extends AEBaseInvTile
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSkyChest(ByteBuf data)
|
||||
{
|
||||
data.writeBoolean( playerOpen > 0 );
|
||||
data.writeBoolean( this.playerOpen > 0 );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSkyChest(ByteBuf data)
|
||||
{
|
||||
int wasOpen = playerOpen;
|
||||
playerOpen = data.readBoolean() ? 1 : 0;
|
||||
int wasOpen = this.playerOpen;
|
||||
this.playerOpen = data.readBoolean() ? 1 : 0;
|
||||
|
||||
if ( wasOpen != playerOpen )
|
||||
lastEvent = System.currentTimeMillis();
|
||||
if ( wasOpen != this.playerOpen )
|
||||
this.lastEvent = System.currentTimeMillis();
|
||||
|
||||
return false; // TESR yo!
|
||||
}
|
||||
@@ -76,13 +76,13 @@ public class TileSkyChest extends AEBaseInvTile
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return inv;
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
{
|
||||
return sides;
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,12 +91,12 @@ public class TileSkyChest extends AEBaseInvTile
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
playerOpen++;
|
||||
this.playerOpen++;
|
||||
|
||||
if ( playerOpen == 1 )
|
||||
if ( this.playerOpen == 1 )
|
||||
{
|
||||
getWorldObj().playSoundEffect( xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestopen", 0.5F, getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
markForUpdate();
|
||||
this.getWorldObj().playSoundEffect( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestopen", 0.5F, this.getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,16 +106,16 @@ public class TileSkyChest extends AEBaseInvTile
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
playerOpen--;
|
||||
this.playerOpen--;
|
||||
|
||||
if ( playerOpen < 0 )
|
||||
playerOpen = 0;
|
||||
if ( this.playerOpen < 0 )
|
||||
this.playerOpen = 0;
|
||||
|
||||
if ( playerOpen == 0 )
|
||||
if ( this.playerOpen == 0 )
|
||||
{
|
||||
getWorldObj().playSoundEffect( xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestclosed", 0.5F,
|
||||
getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
markForUpdate();
|
||||
this.getWorldObj().playSoundEffect( this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, "random.chestclosed", 0.5F,
|
||||
this.getWorldObj().rand.nextFloat() * 0.1F + 0.9F );
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user