Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,6 +42,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
|
||||
public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost
|
||||
{
|
||||
|
||||
@@ -50,21 +52,28 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
IInventory cacheUpgrades = null;
|
||||
IInventory cacheConfig = null;
|
||||
private boolean locked = false;
|
||||
|
||||
public TileCellWorkbench()
|
||||
{
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
public IInventory getCellUpgradeInventory()
|
||||
{
|
||||
if ( this.cacheUpgrades == null )
|
||||
if( this.cacheUpgrades == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getUpgradesInventory( is );
|
||||
if ( inv == null )
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheUpgrades = inv;
|
||||
@@ -72,72 +81,55 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return this.cacheUpgrades;
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if ( cell == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if ( is == null )
|
||||
return null;
|
||||
if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() );
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if ( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCellWorkbench( NBTTagCompound data )
|
||||
{
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
public TileCellWorkbench() {
|
||||
this.cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
this.cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "config" ) )
|
||||
if( name.equals( "config" ) )
|
||||
return this.config;
|
||||
|
||||
if ( name.equals( "cell" ) )
|
||||
if( name.equals( "cell" ) )
|
||||
return this.cell;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean locked = false;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
if ( inv == this.cell && !this.locked )
|
||||
if( inv == this.cell && !this.locked )
|
||||
{
|
||||
this.locked = true;
|
||||
|
||||
@@ -145,34 +137,34 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
this.cacheConfig = null;
|
||||
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
boolean cellHasConfig = false;
|
||||
for (int x = 0; x < c.getSizeInventory(); x++)
|
||||
for( int x = 0; x < c.getSizeInventory(); x++ )
|
||||
{
|
||||
if ( c.getStackInSlot( x ) != null )
|
||||
if( c.getStackInSlot( x ) != null )
|
||||
{
|
||||
cellHasConfig = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cellHasConfig )
|
||||
if( cellHasConfig )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, c.getStackInSlot( x ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
}
|
||||
}
|
||||
else if ( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
else if( this.cm.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
this.config.setInventorySlotContents( x, null );
|
||||
|
||||
this.markDirty();
|
||||
@@ -180,12 +172,12 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
|
||||
this.locked = false;
|
||||
}
|
||||
else if ( inv == this.config && !this.locked )
|
||||
else if( inv == this.config && !this.locked )
|
||||
{
|
||||
IInventory c = this.getCellConfigInventory();
|
||||
if ( c != null )
|
||||
if( c != null )
|
||||
{
|
||||
for (int x = 0; x < this.config.getSizeInventory(); x++)
|
||||
for( int x = 0; x < this.config.getSizeInventory(); x++ )
|
||||
c.setInventorySlotContents( x, this.config.getStackInSlot( x ) );
|
||||
|
||||
c.markDirty();
|
||||
@@ -193,26 +185,36 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getCellConfigInventory()
|
||||
{
|
||||
if( this.cacheConfig == null )
|
||||
{
|
||||
ICellWorkbenchItem cell = this.getCell();
|
||||
if( cell == null )
|
||||
return null;
|
||||
|
||||
ItemStack is = this.cell.getStackInSlot( 0 );
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
IInventory inv = cell.getConfigInventory( is );
|
||||
if( inv == null )
|
||||
return null;
|
||||
|
||||
return this.cacheConfig = inv;
|
||||
}
|
||||
return this.cacheConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ) != null )
|
||||
if( this.cell.getStackInSlot( 0 ) != null )
|
||||
drops.add( this.cell.getStackInSlot( 0 ) );
|
||||
}
|
||||
|
||||
public ICellWorkbenchItem getCell()
|
||||
{
|
||||
if ( this.cell.getStackInSlot( 0 ) == null )
|
||||
return null;
|
||||
|
||||
if ( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem )
|
||||
return ((ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
@@ -220,9 +222,8 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
// nothing here..
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
@@ -50,6 +51,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
{
|
||||
|
||||
@@ -60,14 +62,22 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
int lastUpdate = 0;
|
||||
boolean requiresUpdate = false;
|
||||
|
||||
public TileCharger()
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.internalMaxPower = 1500;
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCharger(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCharger( ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -75,25 +85,25 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
ItemStack is = item.getItemStack();
|
||||
this.inv.setInventorySlotContents( 0, is );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
this.inv.setInventorySlotContents( 0, null );
|
||||
}
|
||||
return false; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCharger(ByteBuf data) throws IOException
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCharger( ByteBuf data ) throws IOException
|
||||
{
|
||||
AEItemStack is = AEItemStack.create( this.getStackInSlot( 0 ) );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileCharger()
|
||||
{
|
||||
if ( this.lastUpdate > 60 && this.requiresUpdate )
|
||||
if( this.lastUpdate > 60 && this.requiresUpdate )
|
||||
{
|
||||
this.requiresUpdate = false;
|
||||
this.markForUpdate();
|
||||
@@ -102,53 +112,52 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
this.lastUpdate++;
|
||||
|
||||
this.tickTickTimer++;
|
||||
if ( this.tickTickTimer < 20 )
|
||||
if( this.tickTickTimer < 20 )
|
||||
return;
|
||||
this.tickTickTimer = 0;
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if ( this.internalCurrentPower < 1499 )
|
||||
if( this.internalCurrentPower < 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.gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
}
|
||||
|
||||
if ( myItem == null )
|
||||
if( myItem == null )
|
||||
return;
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if ( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
if( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if ( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
double oldPower = this.internalCurrentPower;
|
||||
|
||||
double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
this.internalCurrentPower += adjustment;
|
||||
if ( oldPower > this.internalCurrentPower )
|
||||
if( oldPower > this.internalCurrentPower )
|
||||
this.requiresUpdate = true;
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
}
|
||||
else if ( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
else if( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
if ( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
for( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
@@ -156,21 +165,20 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
}
|
||||
|
||||
public TileCharger() {
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.internalMaxPower = 1500;
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
this.setPowerSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTurn()
|
||||
{
|
||||
@@ -183,15 +191,15 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
this.injectExternalPower( PowerUnits.AE, 150 );
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
if ( this.internalCurrentPower > 1499 )
|
||||
if( this.internalCurrentPower > 1499 )
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if ( materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
if( materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
for( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
@@ -200,7 +208,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCrankAttach(ForgeDirection directionToCrank)
|
||||
public boolean canCrankAttach( ForgeDirection directionToCrank )
|
||||
{
|
||||
return this.getUp() == directionToCrank || this.getUp().getOpposite() == directionToCrank;
|
||||
}
|
||||
@@ -211,18 +219,6 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide)
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -230,7 +226,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal();
|
||||
|
||||
@@ -238,29 +234,41 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if ( Platform.isChargeable( extractedItem ) )
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if( Platform.isChargeable( extractedItem ) )
|
||||
{
|
||||
IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem();
|
||||
if ( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem );
|
||||
}
|
||||
|
||||
public void activate(EntityPlayer player)
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection whichSide )
|
||||
{
|
||||
if ( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
public void activate( EntityPlayer player )
|
||||
{
|
||||
if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) )
|
||||
return;
|
||||
|
||||
ItemStack myItem = this.getStackInSlot( 0 );
|
||||
if ( myItem == null )
|
||||
if( myItem == null )
|
||||
{
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
|
||||
if ( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) )
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) )
|
||||
{
|
||||
held = player.inventory.decrStackSize( player.inventory.currentItem, 1 );
|
||||
this.setInventorySlotContents( 0, held );
|
||||
@@ -274,11 +282,4 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
Platform.spawnDrops( this.worldObj, this.xCoord + this.getForward().offsetX, this.yCoord + this.getForward().offsetY, this.zCoord + this.getForward().offsetZ, drops );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -43,59 +44,61 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConfigManagerHost, IConfigurableObject
|
||||
{
|
||||
|
||||
final int[] sides = new int[] { 0, 1 };
|
||||
static private final FluidTankInfo[] EMPTY = new FluidTankInfo[] { new FluidTankInfo( null, 10 ) };
|
||||
final int[] sides = new int[] { 0, 1 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 3 );
|
||||
final ConfigManager cm = new ConfigManager( this );
|
||||
|
||||
public double storedPower = 0;
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCondenser(NBTTagCompound data)
|
||||
public TileCondenser()
|
||||
{
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCondenser( NBTTagCompound data )
|
||||
{
|
||||
this.cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", this.storedPower );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCondenser(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCondenser( NBTTagCompound data )
|
||||
{
|
||||
this.cm.readFromNBT( data );
|
||||
this.storedPower = data.getDouble( "storedPower" );
|
||||
}
|
||||
|
||||
public TileCondenser() {
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
public double getStorage()
|
||||
{
|
||||
ItemStack is = this.inv.getStackInSlot( 2 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
if ( is.getItem() instanceof IStorageComponent )
|
||||
if( is.getItem() instanceof IStorageComponent )
|
||||
{
|
||||
IStorageComponent sc = (IStorageComponent) is.getItem();
|
||||
if ( sc.isStorageComponent( is ) )
|
||||
if( sc.isStorageComponent( is ) )
|
||||
return sc.getBytes( is ) * 8;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addPower(double rawPower)
|
||||
public void addPower( double rawPower )
|
||||
{
|
||||
this.storedPower += rawPower;
|
||||
this.storedPower = Math.max( 0.0, Math.min( this.getStorage(), this.storedPower ) );
|
||||
|
||||
double requiredPower = this.getRequiredPower();
|
||||
ItemStack output = this.getOutput();
|
||||
while (requiredPower <= this.storedPower && output != null && requiredPower > 0)
|
||||
while( requiredPower <= this.storedPower && output != null && requiredPower > 0 )
|
||||
{
|
||||
if ( this.canAddOutput( output ) )
|
||||
if( this.canAddOutput( output ) )
|
||||
{
|
||||
this.storedPower -= requiredPower;
|
||||
this.addOutput( output );
|
||||
@@ -105,10 +108,10 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canAddOutput(ItemStack output)
|
||||
private boolean canAddOutput( ItemStack output )
|
||||
{
|
||||
ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
return outputStack == null || (Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize());
|
||||
return outputStack == null || ( Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,10 +119,10 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
*
|
||||
* @param output to be added output
|
||||
*/
|
||||
private void addOutput(ItemStack output)
|
||||
private void addOutput( ItemStack output )
|
||||
{
|
||||
ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
if ( outputStack == null )
|
||||
if( outputStack == null )
|
||||
this.setInventorySlotContents( 1, output.copy() );
|
||||
else
|
||||
{
|
||||
@@ -132,16 +135,16 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
switch ((CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ))
|
||||
switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
for ( ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return matterBallStack;
|
||||
}
|
||||
|
||||
case SINGULARITY:
|
||||
for ( ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return singularityStack;
|
||||
}
|
||||
@@ -154,45 +157,7 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
|
||||
public double getRequiredPower()
|
||||
{
|
||||
return ((CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT )).requiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
if ( i == 0 )
|
||||
{
|
||||
if ( itemstack != null )
|
||||
this.addPower( itemstack.stackSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setInventorySlotContents( 1, itemstack );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
return slotIndex == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
{
|
||||
return this.sides;
|
||||
return ( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ).requiredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,12 +167,32 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void setInventorySlotContents( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( slot == 0 )
|
||||
if( i == 0 )
|
||||
{
|
||||
if( itemstack != null )
|
||||
this.addPower( itemstack.stackSize );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inv.setInventorySlotContents( 1, itemstack );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
this.addPower( is.stackSize );
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
@@ -216,46 +201,64 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side )
|
||||
{
|
||||
if ( doFill )
|
||||
this.addPower( (resource == null ? 0.0 : (double) resource.amount) / 500.0 );
|
||||
return slotIndex == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return slotIndex != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill( ForgeDirection from, FluidStack resource, boolean doFill )
|
||||
{
|
||||
if( doFill )
|
||||
this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / 500.0 );
|
||||
|
||||
return resource == null ? 0 : resource.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, FluidStack resource, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
public FluidStack drain( ForgeDirection from, int maxDrain, boolean doDrain )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
public boolean canFill( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
public boolean canDrain( ForgeDirection from, Fluid fluid )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
public FluidTankInfo[] getTankInfo( ForgeDirection from )
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.addPower( 0 );
|
||||
}
|
||||
@@ -265,5 +268,4 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
||||
{
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,15 +129,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
boolean oldSmash = this.smash;
|
||||
boolean newSmash = ( slot & 64 ) == 64;
|
||||
|
||||
if ( oldSmash != newSmash && newSmash )
|
||||
if( oldSmash != newSmash && newSmash )
|
||||
{
|
||||
this.smash = true;
|
||||
this.clientStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( ( slot & ( 1 << num ) ) > 0 )
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
this.inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() );
|
||||
else
|
||||
this.inv.setInventorySlotContents( num, null );
|
||||
@@ -151,16 +151,16 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
int slot = this.smash ? 64 : 0;
|
||||
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( this.inv.getStackInSlot( num ) != null )
|
||||
if( this.inv.getStackInSlot( num ) != null )
|
||||
slot |= ( 1 << num );
|
||||
}
|
||||
|
||||
data.writeByte( slot );
|
||||
for ( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
for( int num = 0; num < this.inv.getSizeInventory(); num++ )
|
||||
{
|
||||
if ( ( slot & ( 1 << num ) ) > 0 )
|
||||
if( ( slot & ( 1 << num ) ) > 0 )
|
||||
{
|
||||
AEItemStack st = AEItemStack.create( this.inv.getStackInSlot( num ) );
|
||||
st.writeToPacket( data );
|
||||
@@ -181,10 +181,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
super.getDrops( w, x, y, z, drops );
|
||||
|
||||
for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
|
||||
{
|
||||
ItemStack is = this.upgrades.getStackInSlot( h );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
@@ -204,68 +210,62 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
if ( this.smash )
|
||||
if( this.smash )
|
||||
return false;
|
||||
|
||||
if ( i == 0 || i == 1 )
|
||||
if( i == 0 || i == 1 )
|
||||
{
|
||||
if ( AEApi.instance().definitions().materials().namePress().isSameAs( itemstack ) )
|
||||
if( AEApi.instance().definitions().materials().namePress().isSameAs( itemstack ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for ( ItemStack s : Inscribe.PLATES )
|
||||
if ( Platform.isSameItemPrecise( s, itemstack ) )
|
||||
for( ItemStack s : Inscribe.PLATES )
|
||||
if( Platform.isSameItemPrecise( s, itemstack ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return i == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if ( this.smash )
|
||||
return false;
|
||||
|
||||
return slotIndex == 0 || slotIndex == 1 || slotIndex == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
return this.inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mc != InvOperation.markDirty )
|
||||
if( mc != InvOperation.markDirty )
|
||||
{
|
||||
if ( slot != 3 )
|
||||
if( slot != 3 )
|
||||
this.processingTime = 0;
|
||||
|
||||
if ( !this.smash )
|
||||
if( !this.smash )
|
||||
this.markForUpdate();
|
||||
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
if( this.smash )
|
||||
return false;
|
||||
|
||||
return slotIndex == 0 || slotIndex == 1 || slotIndex == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection d )
|
||||
{
|
||||
if ( d == ForgeDirection.UP )
|
||||
if( d == ForgeDirection.UP )
|
||||
return this.top;
|
||||
|
||||
if ( d == ForgeDirection.DOWN )
|
||||
if( d == ForgeDirection.DOWN )
|
||||
return this.bottom;
|
||||
|
||||
return this.sides;
|
||||
@@ -279,7 +279,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
private boolean hasWork()
|
||||
{
|
||||
if ( this.getTask() != null )
|
||||
if( this.getTask() != null )
|
||||
return true;
|
||||
|
||||
this.processingTime = 0;
|
||||
@@ -292,35 +292,35 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
ItemStack plateB = this.getStackInSlot( 1 );
|
||||
ItemStack renamedItem = this.getStackInSlot( 2 );
|
||||
|
||||
if ( plateA != null && plateA.stackSize > 1 )
|
||||
if( plateA != null && plateA.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
if ( plateB != null && plateB.stackSize > 1 )
|
||||
if( plateB != null && plateB.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
if ( renamedItem != null && renamedItem.stackSize > 1 )
|
||||
if( renamedItem != null && renamedItem.stackSize > 1 )
|
||||
return null;
|
||||
|
||||
final IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
boolean isNameA = namePress.isSameAs( plateA );
|
||||
boolean isNameB = namePress.isSameAs( plateB );
|
||||
|
||||
if ( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) )
|
||||
if( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) )
|
||||
{
|
||||
if ( renamedItem != null )
|
||||
if( renamedItem != null )
|
||||
{
|
||||
String name = "";
|
||||
|
||||
if ( plateA != null )
|
||||
if( plateA != null )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( plateA );
|
||||
name += tag.getString( "InscribeName" );
|
||||
}
|
||||
|
||||
if ( plateB != null )
|
||||
if( plateB != null )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( plateB );
|
||||
if ( name.length() > 0 )
|
||||
if( name.length() > 0 )
|
||||
name += " ";
|
||||
name += tag.getString( "InscribeName" );
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
NBTTagCompound display = tag.getCompoundTag( "display" );
|
||||
tag.setTag( "display", display );
|
||||
|
||||
if ( name.length() > 0 )
|
||||
if( name.length() > 0 )
|
||||
display.setString( "Name", name );
|
||||
else
|
||||
display.removeTag( "Name" );
|
||||
@@ -341,7 +341,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
}
|
||||
}
|
||||
|
||||
for ( InscriberRecipe i : Inscribe.RECIPES )
|
||||
for( InscriberRecipe i : Inscribe.RECIPES )
|
||||
{
|
||||
|
||||
boolean matchA = ( plateA == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateA, i.plateA ) ) && // and...
|
||||
@@ -350,11 +350,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
boolean matchB = ( plateB == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateB, i.plateA ) ) && // and...
|
||||
( plateA == null && i.plateB == null ) | ( Platform.isSameItemPrecise( plateA, i.plateB ) );
|
||||
|
||||
if ( matchA || matchB )
|
||||
if( matchA || matchB )
|
||||
{
|
||||
for ( ItemStack option : i.imprintable )
|
||||
for( ItemStack option : i.imprintable )
|
||||
{
|
||||
if ( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -365,23 +365,23 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.smash )
|
||||
if( this.smash )
|
||||
{
|
||||
|
||||
this.finalStep++;
|
||||
if ( this.finalStep == 8 )
|
||||
if( this.finalStep == 8 )
|
||||
{
|
||||
|
||||
InscriberRecipe out = this.getTask();
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
{
|
||||
ItemStack is = out.output.copy();
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, 3, 1, true ), ForgeDirection.UNKNOWN );
|
||||
|
||||
if ( ad.addItems( is ) == null )
|
||||
if( ad.addItems( is ) == null )
|
||||
{
|
||||
this.processingTime = 0;
|
||||
if ( out.usePlates )
|
||||
if( out.usePlates )
|
||||
{
|
||||
this.setInventorySlotContents( 0, null );
|
||||
this.setInventorySlotContents( 1, null );
|
||||
@@ -392,7 +392,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
else if ( this.finalStep == 16 )
|
||||
else if( this.finalStep == 16 )
|
||||
{
|
||||
this.finalStep = 0;
|
||||
this.smash = false;
|
||||
@@ -413,36 +413,36 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
double powerThreshold = powerConsumption - 0.01;
|
||||
double powerReq = this.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
if ( powerReq <= powerThreshold )
|
||||
if( powerReq <= powerThreshold )
|
||||
{
|
||||
src = eg;
|
||||
powerReq = eg.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG );
|
||||
}
|
||||
|
||||
if ( powerReq > powerThreshold )
|
||||
if( powerReq > powerThreshold )
|
||||
{
|
||||
src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
if ( this.processingTime == 0 )
|
||||
if( this.processingTime == 0 )
|
||||
this.processingTime += speedFactor;
|
||||
else
|
||||
this.processingTime += TicksSinceLastCall * speedFactor;
|
||||
}
|
||||
}
|
||||
catch ( GridAccessException e )
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
if ( this.processingTime > this.maxProcessingTime )
|
||||
if( this.processingTime > this.maxProcessingTime )
|
||||
{
|
||||
this.processingTime = this.maxProcessingTime;
|
||||
InscriberRecipe out = this.getTask();
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
{
|
||||
ItemStack is = out.output.copy();
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, 3, 1, true ), ForgeDirection.UNKNOWN );
|
||||
if ( ad.simulateAdd( is ) == null )
|
||||
if( ad.simulateAdd( is ) == null )
|
||||
{
|
||||
this.smash = true;
|
||||
this.finalStep = 0;
|
||||
@@ -464,10 +464,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
@Override
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
if ( name.equals( "inv" ) )
|
||||
if( name.equals( "inv" ) )
|
||||
return this.inv;
|
||||
|
||||
if ( name.equals( "upgrades" ) )
|
||||
if( name.equals( "upgrades" ) )
|
||||
return this.upgrades;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,6 +30,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||
@@ -62,40 +63,40 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ITileStorageMonitorable, IStorageMonitorable,
|
||||
IInventoryDestination, IInterfaceHost, IPriorityHost
|
||||
|
||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ITileStorageMonitorable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, IPriorityHost
|
||||
{
|
||||
|
||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||
final DualityInterface duality = new DualityInterface( this.gridProxy, this );
|
||||
ForgeDirection pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkChannelsChanged c)
|
||||
public void stateChange( MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(MENetworkPowerStatusChange c)
|
||||
public void stateChange( MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
public void setSide(ForgeDirection axis)
|
||||
public void setSide( ForgeDirection axis )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
if ( this.pointAt == axis.getOpposite() )
|
||||
if( this.pointAt == axis.getOpposite() )
|
||||
this.pointAt = axis;
|
||||
else if ( this.pointAt == axis || this.pointAt == axis.getOpposite() )
|
||||
else if( this.pointAt == axis || this.pointAt == axis.getOpposite() )
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
else if ( this.pointAt == ForgeDirection.UNKNOWN )
|
||||
else if( this.pointAt == ForgeDirection.UNKNOWN )
|
||||
this.pointAt = axis.getOpposite();
|
||||
else
|
||||
this.pointAt = Platform.rotateAround( this.pointAt, axis );
|
||||
|
||||
if ( ForgeDirection.UNKNOWN == this.pointAt )
|
||||
if( ForgeDirection.UNKNOWN == this.pointAt )
|
||||
this.setOrientation( this.pointAt, this.pointAt );
|
||||
else
|
||||
this.setOrientation( this.pointAt.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP, this.pointAt.getOpposite() );
|
||||
@@ -106,7 +107,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void markDirty()
|
||||
{
|
||||
this.duality.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
this.duality.addDrops( drops );
|
||||
}
|
||||
@@ -117,26 +124,6 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
this.duality.gridChanged();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "pointAt", this.pointAt.ordinal() );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if ( val >= 0 && val < ForgeDirection.values().length )
|
||||
this.pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
@@ -145,8 +132,28 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInterface( NBTTagCompound data )
|
||||
{
|
||||
data.setInteger( "pointAt", this.pointAt.ordinal() );
|
||||
this.duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInterface( NBTTagCompound data )
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if( val >= 0 && val < ForgeDirection.values().length )
|
||||
this.pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
this.pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return this.duality.getCableConnectionType( dir );
|
||||
}
|
||||
@@ -158,13 +165,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(ItemStack stack)
|
||||
public boolean canInsert( ItemStack stack )
|
||||
{
|
||||
return this.duality.canInsert( stack );
|
||||
}
|
||||
@@ -182,19 +183,19 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
public IInventory getInventoryByName( String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return this.duality.getTickingRequest( node );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return this.duality.tickingRequest( node, TicksSinceLastCall );
|
||||
}
|
||||
@@ -206,19 +207,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.duality.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
this.duality.onChangeInventory( inv, slot, mc, removed, added );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.duality.getAccessibleSlotsFromSide( side.ordinal() );
|
||||
}
|
||||
@@ -230,7 +225,21 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN )
|
||||
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||
return EnumSet.of( this.pointAt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src )
|
||||
{
|
||||
return this.duality.getMonitorable( side, src, this );
|
||||
}
|
||||
@@ -242,25 +251,11 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
|
||||
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
||||
{
|
||||
return this.duality.pushPattern( patternDetails, table );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getTargets()
|
||||
{
|
||||
if ( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN )
|
||||
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||
return EnumSet.of( this.pointAt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
@@ -268,7 +263,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades(Upgrades u)
|
||||
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
||||
{
|
||||
this.duality.provideCrafting( craftingTracker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
@@ -280,13 +281,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
|
||||
{
|
||||
return this.duality.injectCraftedItems( link, items, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobStateChange(ICraftingLink link)
|
||||
public void jobStateChange( ICraftingLink link )
|
||||
{
|
||||
this.duality.jobStateChange( link );
|
||||
}
|
||||
@@ -298,7 +299,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
this.duality.setPriority( newValue );
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -34,11 +36,11 @@ public class TileLightDetector extends AEBaseTile
|
||||
return this.lastLight > 0;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileLightDetector()
|
||||
{
|
||||
this.lastCheck++;
|
||||
if ( this.lastCheck > 30 )
|
||||
if( this.lastCheck > 30 )
|
||||
{
|
||||
this.lastCheck = 0;
|
||||
this.updateLight();
|
||||
@@ -49,7 +51,7 @@ public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
int val = this.worldObj.getBlockLightValue( this.xCoord, this.yCoord, this.zCoord );
|
||||
|
||||
if ( this.lastLight != val )
|
||||
if( this.lastLight != val )
|
||||
{
|
||||
this.lastLight = val;
|
||||
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
|
||||
@@ -61,5 +63,4 @@ public class TileLightDetector extends AEBaseTile
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -35,6 +34,8 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
@@ -42,6 +43,7 @@ import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -50,9 +52,18 @@ public class TilePaint extends AEBaseTile
|
||||
int isLit = 0;
|
||||
ArrayList<Splotch> dots = null;
|
||||
|
||||
void writeBuffer(ByteBuf out)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TilePaint( NBTTagCompound data )
|
||||
{
|
||||
if ( this.dots == null )
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
|
||||
void writeBuffer( ByteBuf out )
|
||||
{
|
||||
if( this.dots == null )
|
||||
{
|
||||
out.writeByte( 0 );
|
||||
return;
|
||||
@@ -60,15 +71,22 @@ public class TilePaint extends AEBaseTile
|
||||
|
||||
out.writeByte( this.dots.size() );
|
||||
|
||||
for (Splotch s : this.dots)
|
||||
for( Splotch s : this.dots )
|
||||
s.writeToStream( out );
|
||||
}
|
||||
|
||||
void readBuffer(ByteBuf in)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TilePaint( NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( "dots" ) )
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
void readBuffer( ByteBuf in )
|
||||
{
|
||||
byte howMany = in.readByte();
|
||||
|
||||
if ( howMany == 0 )
|
||||
if( howMany == 0 )
|
||||
{
|
||||
this.isLit = 0;
|
||||
this.dots = null;
|
||||
@@ -76,13 +94,13 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
|
||||
this.dots = new ArrayList( howMany );
|
||||
for (int x = 0; x < howMany; x++)
|
||||
for( int x = 0; x < howMany; x++ )
|
||||
this.dots.add( new Splotch( in ) );
|
||||
|
||||
this.isLit = 0;
|
||||
for (Splotch s : this.dots)
|
||||
for( Splotch s : this.dots )
|
||||
{
|
||||
if ( s.lumen )
|
||||
if( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
@@ -91,30 +109,23 @@ public class TilePaint extends AEBaseTile
|
||||
this.maxLit();
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TilePaint(NBTTagCompound data)
|
||||
private void maxLit()
|
||||
{
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if ( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
if( this.isLit > 14 )
|
||||
this.isLit = 14;
|
||||
|
||||
if( this.worldObj != null )
|
||||
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TilePaint(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "dots" ) )
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TilePaint(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TilePaint( ByteBuf data )
|
||||
{
|
||||
this.writeBuffer( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TilePaint(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TilePaint( ByteBuf data )
|
||||
{
|
||||
this.readBuffer( data );
|
||||
return true;
|
||||
@@ -122,61 +133,31 @@ public class TilePaint extends AEBaseTile
|
||||
|
||||
public void onNeighborBlockChange()
|
||||
{
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
return;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
||||
{
|
||||
if ( !this.isSideValid( side ) )
|
||||
if( !this.isSideValid( side ) )
|
||||
this.removeSide( side );
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
this.isLit = 0;
|
||||
for (Splotch s : this.dots)
|
||||
{
|
||||
if ( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
|
||||
if ( this.dots.isEmpty() )
|
||||
this.dots = null;
|
||||
|
||||
if ( this.dots == null )
|
||||
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
|
||||
}
|
||||
|
||||
public void cleanSide(ForgeDirection side)
|
||||
{
|
||||
if ( this.dots == null )
|
||||
return;
|
||||
|
||||
this.removeSide( side );
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
public boolean isSideValid(ForgeDirection side)
|
||||
public boolean isSideValid( ForgeDirection side )
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
|
||||
return blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() );
|
||||
}
|
||||
|
||||
private void removeSide(ForgeDirection side)
|
||||
private void removeSide( ForgeDirection side )
|
||||
{
|
||||
Iterator<Splotch> i = this.dots.iterator();
|
||||
while (i.hasNext())
|
||||
while( i.hasNext() )
|
||||
{
|
||||
Splotch s = i.next();
|
||||
if ( s.side == side )
|
||||
if( s.side == side )
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@@ -184,29 +165,59 @@ public class TilePaint extends AEBaseTile
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
private void updateData()
|
||||
{
|
||||
this.isLit = 0;
|
||||
for( Splotch s : this.dots )
|
||||
{
|
||||
if( s.lumen )
|
||||
{
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
}
|
||||
}
|
||||
|
||||
this.maxLit();
|
||||
|
||||
if( this.dots.isEmpty() )
|
||||
this.dots = null;
|
||||
|
||||
if( this.dots == null )
|
||||
this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air );
|
||||
}
|
||||
|
||||
public void cleanSide( ForgeDirection side )
|
||||
{
|
||||
if( this.dots == null )
|
||||
return;
|
||||
|
||||
this.removeSide( side );
|
||||
|
||||
this.updateData();
|
||||
}
|
||||
|
||||
public int getLightLevel()
|
||||
{
|
||||
return this.isLit;
|
||||
}
|
||||
|
||||
public void addBlot(ItemStack type, ForgeDirection side, Vec3 hitVec)
|
||||
public void addBlot( ItemStack type, ForgeDirection side, Vec3 hitVec )
|
||||
{
|
||||
Block blk = this.worldObj.getBlock( this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ );
|
||||
if ( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
|
||||
if( blk.isSideSolid( this.worldObj, this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ, side.getOpposite() ) )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
|
||||
AEColor col = ipb.getColor( type );
|
||||
boolean lit = ipb.isLumen( type );
|
||||
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
this.dots = new ArrayList<Splotch>();
|
||||
|
||||
if ( this.dots.size() > 20 )
|
||||
if( this.dots.size() > 20 )
|
||||
this.dots.remove( 0 );
|
||||
|
||||
this.dots.add( new Splotch( col, lit, side, hitVec ) );
|
||||
if ( lit )
|
||||
if( lit )
|
||||
this.isLit += LIGHT_PER_DOT;
|
||||
|
||||
this.maxLit();
|
||||
@@ -215,18 +226,9 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
private void maxLit()
|
||||
{
|
||||
if ( this.isLit > 14 )
|
||||
this.isLit = 14;
|
||||
|
||||
if ( this.worldObj != null )
|
||||
this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord );
|
||||
}
|
||||
|
||||
public Collection<Splotch> getDots()
|
||||
{
|
||||
if ( this.dots == null )
|
||||
if( this.dots == null )
|
||||
return ImmutableList.of();
|
||||
|
||||
return this.dots;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -35,52 +36,54 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState, ICrystalGrowthAccelerator
|
||||
{
|
||||
|
||||
public boolean hasPower = false;
|
||||
|
||||
public TileQuartzGrowthAccelerator()
|
||||
{
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.gridProxy.setIdlePowerUsage( 8 );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPower(MENetworkPowerStatusChange ch)
|
||||
public void onPower( MENetworkPowerStatusChange ch )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator( ByteBuf data )
|
||||
{
|
||||
boolean hadPower = this.hasPower;
|
||||
this.hasPower = data.readBoolean();
|
||||
return this.hasPower != hadPower;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileQuartzGrowthAccelerator(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileQuartzGrowthAccelerator( ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
data.writeBoolean( this.gridProxy.getEnergy().isNetworkPowered() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
}
|
||||
|
||||
public TileQuartzGrowthAccelerator() {
|
||||
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
this.gridProxy.setFlags();
|
||||
this.gridProxy.setIdlePowerUsage( 8 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
|
||||
public void setOrientation( ForgeDirection inForward, ForgeDirection inUp )
|
||||
{
|
||||
super.setOrientation( inForward, inUp );
|
||||
this.gridProxy.setValidSides( EnumSet.of( this.getUp(), this.getUp().getOpposite() ) );
|
||||
@@ -89,13 +92,13 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.gridProxy.getEnergy().isNetworkPowered();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -109,5 +112,4 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
{
|
||||
return this.isPowered();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,35 +77,47 @@ import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost, ISecurityProvider, IColorableTile
|
||||
{
|
||||
|
||||
private static int difference = 0;
|
||||
public 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 boolean isActive = false;
|
||||
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
public long securityKey;
|
||||
public TileSecurity()
|
||||
{
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.gridProxy.setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
|
||||
public final AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if( difference > 10 )
|
||||
difference = 0;
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||
public void getDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
|
||||
{
|
||||
if ( !this.configSlot.isEmpty() )
|
||||
if( !this.configSlot.isEmpty() )
|
||||
drops.add( this.configSlot.getStackInSlot( 0 ) );
|
||||
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
drops.add( ais.getItemStack() );
|
||||
}
|
||||
|
||||
@@ -114,35 +126,8 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSecurity(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSecurity( ByteBuf data )
|
||||
{
|
||||
boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
@@ -153,15 +138,15 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSecurity(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSecurity( ByteBuf data )
|
||||
{
|
||||
data.writeBoolean( this.gridProxy.isActive() );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileSecurity(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSecurity( NBTTagCompound data )
|
||||
{
|
||||
this.cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
@@ -172,7 +157,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
NBTTagCompound storedItems = new NBTTagCompound();
|
||||
|
||||
int offset = 0;
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
{
|
||||
NBTTagCompound it = new NBTTagCompound();
|
||||
ais.getItemStack().writeToNBT( it );
|
||||
@@ -183,21 +168,21 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
data.setTag( "storedItems", storedItems );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileSecurity(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSecurity( NBTTagCompound data )
|
||||
{
|
||||
this.cm.readFromNBT( data );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
|
||||
this.securityKey = data.getLong( "securityKey" );
|
||||
this.configSlot.readFromNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
||||
for (Object key : storedItems.func_150296_c())
|
||||
for( Object key : storedItems.func_150296_c() )
|
||||
{
|
||||
NBTBase obj = storedItems.getTag( (String) key );
|
||||
if ( obj instanceof NBTTagCompound )
|
||||
if( obj instanceof NBTTagCompound )
|
||||
{
|
||||
this.inventory.storedItems.add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
|
||||
}
|
||||
@@ -211,77 +196,57 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
this.saveChanges();
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkSecurityChange() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPermissions(HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms)
|
||||
{
|
||||
IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
|
||||
// read permissions
|
||||
for (IAEItemStack ais : this.inventory.storedItems)
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
Item i = is.getItem();
|
||||
if ( i instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put( this.gridProxy.getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootUpdate(MENetworkChannelsChanged changed)
|
||||
public void bootUpdate( MENetworkChannelsChanged changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerUpdate(MENetworkPowerStatusChange changed)
|
||||
public void powerUpdate( MENetworkPowerStatusChange changed )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled()
|
||||
{
|
||||
return this.isActive && this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
public TileSecurity() {
|
||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.gridProxy.setIdlePowerUsage( 2.0 );
|
||||
difference++;
|
||||
|
||||
this.securityKey = System.currentTimeMillis() * 10 + difference;
|
||||
if ( difference > 10 )
|
||||
difference = 0;
|
||||
|
||||
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
return this.gridProxy.getNode().getPlayerID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
super.onReady();
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.isActive = true;
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Register ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
this.isActive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
@@ -323,7 +288,7 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -334,6 +299,39 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPermissions( HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms )
|
||||
{
|
||||
IPlayerRegistry pr = AEApi.instance().registries().players();
|
||||
|
||||
// read permissions
|
||||
for( IAEItemStack ais : this.inventory.storedItems )
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
Item i = is.getItem();
|
||||
if( i instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) i;
|
||||
bc.registerPermissions( new PlayerSecurityWrapper( playerPerms ), pr, is );
|
||||
}
|
||||
}
|
||||
|
||||
// make sure thea admin is Boss.
|
||||
playerPerms.put( this.gridProxy.getNode().getPlayerID(), EnumSet.allOf( SecurityPermissions.class ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecurityEnabled()
|
||||
{
|
||||
return this.isActive && this.gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
return this.gridProxy.getNode().getPlayerID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
@@ -341,9 +339,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, AEColor newPaintedColor, EntityPlayer who)
|
||||
public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who )
|
||||
{
|
||||
if ( this.paintedColor == newPaintedColor )
|
||||
if( this.paintedColor == newPaintedColor )
|
||||
return false;
|
||||
|
||||
this.paintedColor = newPaintedColor;
|
||||
@@ -351,5 +349,4 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
this.markForUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public class TileSkyCompass extends AEBaseTile
|
||||
{
|
||||
|
||||
@@ -28,5 +30,4 @@ public class TileSkyCompass extends AEBaseTile
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -42,6 +43,7 @@ import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public class TileVibrationChamber extends AENetworkInvTile implements IGridTickable
|
||||
{
|
||||
|
||||
@@ -57,47 +59,48 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
// client side..
|
||||
public boolean isOn;
|
||||
|
||||
public TileVibrationChamber()
|
||||
{
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
this.gridProxy.setFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
public AECableType getCableConnectionType( ForgeDirection dir )
|
||||
{
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileVibrationChamber(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileVibrationChamber( ByteBuf data )
|
||||
{
|
||||
boolean wasOn = this.isOn;
|
||||
this.isOn = data.readBoolean();
|
||||
return wasOn != this.isOn; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileVibrationChamber(ByteBuf data)
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileVibrationChamber( ByteBuf data )
|
||||
{
|
||||
data.writeBoolean( this.burnTime > 0 );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileVibrationChamber( NBTTagCompound data )
|
||||
{
|
||||
data.setDouble( "burnTime", this.burnTime );
|
||||
data.setDouble( "maxBurnTime", this.maxBurnTime );
|
||||
data.setInteger( "burnSpeed", this.burnSpeed );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileVibrationChamber( NBTTagCompound data )
|
||||
{
|
||||
this.burnTime = data.getDouble( "burnTime" );
|
||||
this.maxBurnTime = data.getDouble( "maxBurnTime" );
|
||||
this.burnSpeed = data.getInteger( "burnSpeed" );
|
||||
}
|
||||
|
||||
public TileVibrationChamber() {
|
||||
this.gridProxy.setIdlePowerUsage( 0 );
|
||||
this.gridProxy.setFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory()
|
||||
{
|
||||
@@ -105,17 +108,29 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added)
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( int i, ItemStack itemstack )
|
||||
{
|
||||
return TileEntityFurnace.getItemBurnTime( itemstack ) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added )
|
||||
{
|
||||
if( this.burnTime <= 0 )
|
||||
{
|
||||
if ( this.canEatFuel() )
|
||||
if( this.canEatFuel() )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// wake up!
|
||||
}
|
||||
@@ -124,26 +139,26 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection side)
|
||||
public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide( ForgeDirection side )
|
||||
{
|
||||
return this.sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return TileEntityFurnace.getItemBurnTime( itemstack ) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack extractedItem, int side )
|
||||
private boolean canEatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if( newBurnTime > 0 && is.stackSize > 0 )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,22 +169,22 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node)
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
if( this.burnTime <= 0 )
|
||||
this.eatFuel();
|
||||
|
||||
return new TickingRequest( TickRates.VibrationChamber.min, TickRates.VibrationChamber.max, this.burnTime <= 0, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
if ( this.burnTime <= 0 )
|
||||
if( this.burnTime <= 0 )
|
||||
{
|
||||
this.eatFuel();
|
||||
|
||||
if ( this.burnTime > 0 )
|
||||
if( this.burnTime > 0 )
|
||||
return TickRateModulation.URGENT;
|
||||
|
||||
this.burnSpeed = 100;
|
||||
@@ -181,7 +196,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
|
||||
double timePassed = TicksSinceLastCall * dilation;
|
||||
this.burnTime -= timePassed;
|
||||
if ( this.burnTime < 0 )
|
||||
if( this.burnTime < 0 )
|
||||
{
|
||||
timePassed += this.burnTime;
|
||||
this.burnTime = 0;
|
||||
@@ -196,7 +211,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
// burn the over flow.
|
||||
grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE );
|
||||
|
||||
if ( overFlow > 0 )
|
||||
if( overFlow > 0 )
|
||||
this.burnSpeed -= TicksSinceLastCall;
|
||||
else
|
||||
this.burnSpeed += TicksSinceLastCall;
|
||||
@@ -204,7 +219,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) );
|
||||
return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
this.burnSpeed -= TicksSinceLastCall;
|
||||
this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) );
|
||||
@@ -212,34 +227,22 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canEatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if ( newBurnTime > 0 && is.stackSize > 0 )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void eatFuel()
|
||||
{
|
||||
ItemStack is = this.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
|
||||
if ( newBurnTime > 0 && is.stackSize > 0 )
|
||||
if( newBurnTime > 0 && is.stackSize > 0 )
|
||||
{
|
||||
this.burnTime += newBurnTime;
|
||||
this.maxBurnTime = this.burnTime;
|
||||
is.stackSize--;
|
||||
if ( is.stackSize <= 0 )
|
||||
if( is.stackSize <= 0 )
|
||||
{
|
||||
ItemStack container = null;
|
||||
|
||||
if ( is.getItem().hasContainerItem( is ) )
|
||||
if( is.getItem().hasContainerItem( is ) )
|
||||
container = is.getItem().getContainerItem( is );
|
||||
|
||||
this.setInventorySlotContents( 0, container );
|
||||
@@ -249,19 +252,19 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.burnTime > 0 )
|
||||
if( this.burnTime > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// gah!
|
||||
}
|
||||
}
|
||||
|
||||
if ( (!this.isOn && this.burnTime > 0) || (this.isOn && this.burnTime <= 0) )
|
||||
if( ( !this.isOn && this.burnTime > 0 ) || ( this.isOn && this.burnTime <= 0 ) )
|
||||
{
|
||||
this.isOn = this.burnTime > 0;
|
||||
this.markForUpdate();
|
||||
|
||||
Reference in New Issue
Block a user