Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -18,6 +18,7 @@
package appeng.tile.networking;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -56,31 +57,37 @@ import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.util.Platform;
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
{
public CableBusContainer cb = new CableBusContainer( this );
/**
* Immibis MB Support
*/
boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
private int oldLV = -1; // on re-calculate light when it changes
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBT_TileCableBus(NBTTagCompound data)
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileCableBus( NBTTagCompound data )
{
this.cb.readFromNBT( data );
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeToNBT_TileCableBus(NBTTagCompound data)
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TileCableBus( NBTTagCompound data )
{
this.cb.writeToNBT( data );
}
@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileCableBus(ByteBuf data) throws IOException
@TileEvent( TileEventType.NETWORK_READ )
public boolean readFromStream_TileCableBus( ByteBuf data ) throws IOException
{
boolean ret = this.cb.readFromStream( data );
int newLV = this.cb.getLightValue();
if ( newLV != this.oldLV )
if( newLV != this.oldLV )
{
this.oldLV = newLV;
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
@@ -91,21 +98,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
return ret;
}
@TileEvent(TileEventType.NETWORK_WRITE)
public void writeToStream_TileCableBus(ByteBuf data) throws IOException
{
this.cb.writeToStream( data );
}
@Override
public boolean isInWorld()
{
return this.cb.isInWorld();
}
protected void updateTileSetting()
{
if ( this.cb.requiresDynamicRender )
if( this.cb.requiresDynamicRender )
{
TileCableBus tcb;
try
@@ -114,14 +109,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
tcb.copyFrom( this );
this.getWorldObj().setTileEntity( this.xCoord, this.yCoord, this.zCoord, tcb );
}
catch (Throwable ignored)
catch( Throwable ignored )
{
}
}
}
protected void copyFrom(TileCableBus oldTile)
protected void copyFrom( TileCableBus oldTile )
{
CableBusContainer tmpCB = this.cb;
this.cb = oldTile.cb;
@@ -129,23 +124,22 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
oldTile.cb = tmpCB;
}
@Override
public void onReady()
@TileEvent( TileEventType.NETWORK_WRITE )
public void writeToStream_TileCableBus( ByteBuf data ) throws IOException
{
super.onReady();
if ( this.cb.isEmpty() )
{
if ( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this )
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
}
else
this.cb.addToWorld();
this.cb.writeToStream( data );
}
@Override
public void onChunkUnload()
public double getMaxRenderDistanceSquared()
{
super.onChunkUnload();
return 900.0;
}
@Override
public void invalidate()
{
super.invalidate();
this.cb.removeFromWorld();
}
@@ -157,70 +151,15 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
public void invalidate()
{
super.invalidate();
this.cb.removeFromWorld();
}
@Override
public boolean canBeRotated()
{
return false;
}
@Override
public double getMaxRenderDistanceSquared()
{
return 900.0;
}
@Override
public void getDrops(World w, int x, int y, int z, ArrayList drops)
{
this.cb.getDrops( drops );
}
@Override
public void getNoDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
{
this.cb.getNoDrops( drops );
}
@Override
public IGridNode getGridNode(ForgeDirection dir)
public IGridNode getGridNode( ForgeDirection dir )
{
return this.cb.getGridNode( dir );
}
@Override
public boolean canAddPart(ItemStack is, ForgeDirection side)
public AECableType getCableConnectionType( ForgeDirection side )
{
return this.cb.canAddPart( is, side );
}
@Override
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer player)
{
return this.cb.addPart( is, side, player );
}
@Override
public void removePart(ForgeDirection side, boolean suppressUpdate)
{
this.cb.removePart( side, suppressUpdate );
}
@Override
public IPart getPart(ForgeDirection side)
{
return this.cb.getPart( side );
}
@Override
public DimensionalCoord getLocation()
{
return new DimensionalCoord( this );
return this.cb.getCableConnectionType( side );
}
@Override
@@ -230,56 +169,20 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean visual)
public void onChunkUnload()
{
return this.cb.getSelectedBoundingBoxesFromPool( false, true, e, visual );
}
@Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e)
{
for (AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ))
out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
}
@Override
public AECableType getCableConnectionType(ForgeDirection side)
{
return this.cb.getCableConnectionType( side );
}
@Override
public AEColor getColor()
{
return this.cb.getColor();
}
@Override
public IFacadeContainer getFacadeContainer()
{
return this.cb.getFacadeContainer();
}
@Override
public void clearContainer()
{
this.cb = new CableBusContainer( this );
}
@Override
public boolean isBlocked(ForgeDirection side)
{
return !this.ImmibisMicroblocks_isSideOpen( side.ordinal() );
super.onChunkUnload();
this.cb.removeFromWorld();
}
@Override
public void markForUpdate()
{
if ( this.worldObj == null )
if( this.worldObj == null )
return;
int newLV = this.cb.getLightValue();
if ( newLV != this.oldLV )
if( newLV != this.oldLV )
{
this.oldLV = newLV;
this.worldObj.func_147451_t( this.xCoord, this.yCoord, this.zCoord );
@@ -290,24 +193,106 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
public SelectedPart selectPart(Vec3 pos)
public boolean canBeRotated()
{
return false;
}
@Override
public void getDrops( World w, int x, int y, int z, ArrayList drops )
{
this.cb.getDrops( drops );
}
@Override
public void getNoDrops( World w, int x, int y, int z, ArrayList<ItemStack> drops )
{
this.cb.getNoDrops( drops );
}
@Override
public void onReady()
{
super.onReady();
if( this.cb.isEmpty() )
{
if( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this )
this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true );
}
else
this.cb.addToWorld();
}
@Override
public boolean requiresTESR()
{
return this.cb.requiresDynamicRender;
}
@Override
public IFacadeContainer getFacadeContainer()
{
return this.cb.getFacadeContainer();
}
@Override
public boolean canAddPart( ItemStack is, ForgeDirection side )
{
return this.cb.canAddPart( is, side );
}
@Override
public ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer player )
{
return this.cb.addPart( is, side, player );
}
@Override
public IPart getPart( ForgeDirection side )
{
return this.cb.getPart( side );
}
@Override
public void removePart( ForgeDirection side, boolean suppressUpdate )
{
this.cb.removePart( side, suppressUpdate );
}
@Override
public DimensionalCoord getLocation()
{
return new DimensionalCoord( this );
}
@Override
public AEColor getColor()
{
return this.cb.getColor();
}
@Override
public void clearContainer()
{
this.cb = new CableBusContainer( this );
}
@Override
public boolean isBlocked( ForgeDirection side )
{
return !this.ImmibisMicroblocks_isSideOpen( side.ordinal() );
} @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean visual )
{
return this.cb.getSelectedBoundingBoxesFromPool( false, true, e, visual );
}
@Override
public SelectedPart selectPart( Vec3 pos )
{
return this.cb.selectPart( pos );
}
@Override
public void partChanged()
{
this.notifyNeighbors();
}
@Override
public void notifyNeighbors()
{
if ( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() )
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
}
@Override
public void markForSave()
{
@@ -315,7 +300,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
public boolean hasRedstone(ForgeDirection side)
public void partChanged()
{
this.notifyNeighbors();
}
@Override
public boolean hasRedstone( ForgeDirection side )
{
return this.cb.hasRedstone( side );
}
@@ -326,12 +317,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
return this.cb.isEmpty();
}
@Override
public boolean requiresTESR()
{
return this.cb.requiresDynamicRender;
}
@Override
public Set<LayerFlags> getLayerFlags()
{
@@ -341,23 +326,35 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
@Override
public void cleanup()
{
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
if( AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
{
IImmibisMicroblocks imb = (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks );
if ( imb != null && imb.leaveParts( this ) )
if( imb != null && imb.leaveParts( this ) )
return;
}
this.getWorldObj().setBlock( this.xCoord, this.yCoord, this.zCoord, Platform.AIR );
} @Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
{
for( AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ) )
out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
}
/**
* Immibis MB Support
*/
@Override
public void notifyNeighbors()
{
if( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() )
Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord );
}
boolean ImmibisMicroblocks_TransformableTileEntityMarker = true;
@Override
public boolean isInWorld()
{
return this.cb.isInWorld();
}
public boolean ImmibisMicroblocks_isSideOpen(int side)
public boolean ImmibisMicroblocks_isSideOpen( int side )
{
return true;
}
@@ -368,9 +365,12 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
public boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who)
public boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who )
{
return this.cb.recolourBlock( side, colour, who );
}
}
@@ -18,15 +18,17 @@
package appeng.tile.networking;
import appeng.block.networking.BlockCableBus;
public class TileCableBusTESR extends TileCableBus
{
@Override
protected void updateTileSetting()
{
if ( !this.cb.requiresDynamicRender )
if( !this.cb.requiresDynamicRender )
{
TileCableBus tcb;
try
@@ -35,11 +37,10 @@ public class TileCableBusTESR extends TileCableBus
tcb.copyFrom( this );
this.getWorldObj().setTileEntity( this.xCoord, this.yCoord, this.zCoord, tcb );
}
catch (Throwable ignored)
catch( Throwable ignored )
{
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.tile.networking;
import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
@@ -38,12 +39,16 @@ import appeng.tile.grid.AENetworkPowerTile;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class TileController extends AENetworkPowerTile
{
static final AppEngInternalInventory inv = new AppEngInternalInventory( null, 0 );
final int[] sides = new int[] {};
boolean isValid = false;
public TileController() {
public TileController()
{
this.internalMaxPower = 8000;
this.internalPublicPowerStorage = true;
this.gridProxy.setIdlePowerUsage( 3 );
@@ -51,67 +56,11 @@ public class TileController extends AENetworkPowerTile
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.DENSE;
}
@Override
protected double getFunnelPowerDemand(double maxReceived)
{
try
{
return this.gridProxy.getEnergy().getEnergyDemand( 8000 );
}
catch (GridAccessException e)
{
// no grid? use local...
return super.getFunnelPowerDemand( maxReceived );
}
}
@Override
protected double funnelPowerIntoStorage(double AEUnits, Actionable mode)
{
try
{
double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode );
if ( mode == Actionable.SIMULATE )
return ret;
return 0;
}
catch (GridAccessException e)
{
// no grid? use local...
return super.funnelPowerIntoStorage( AEUnits, mode );
}
}
@Override
protected void PowerEvent(PowerEventType x)
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
}
catch (GridAccessException e)
{
// not ready!
}
}
@MENetworkEventSubscribe
public void onControllerChange(MENetworkControllerChange status)
{
this.updateMeta();
}
@MENetworkEventSubscribe
public void onPowerChange(MENetworkPowerStatusChange status)
{
this.updateMeta();
}
@Override
public void onReady()
{
@@ -119,14 +68,11 @@ public class TileController extends AENetworkPowerTile
super.onReady();
}
public void onNeighborChange(boolean force)
public void onNeighborChange( boolean force )
{
boolean xx = this.worldObj.getTileEntity( this.xCoord - 1, this.yCoord, this.zCoord ) instanceof TileController
&& this.worldObj.getTileEntity( this.xCoord + 1, this.yCoord, this.zCoord ) instanceof TileController;
boolean yy = this.worldObj.getTileEntity( this.xCoord, this.yCoord - 1, this.zCoord ) instanceof TileController
&& this.worldObj.getTileEntity( this.xCoord, this.yCoord + 1, this.zCoord ) instanceof TileController;
boolean zz = this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord - 1 ) instanceof TileController
&& this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord + 1 ) instanceof TileController;
boolean xx = this.worldObj.getTileEntity( this.xCoord - 1, this.yCoord, this.zCoord ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord + 1, this.yCoord, this.zCoord ) instanceof TileController;
boolean yy = this.worldObj.getTileEntity( this.xCoord, this.yCoord - 1, this.zCoord ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord, this.yCoord + 1, this.zCoord ) instanceof TileController;
boolean zz = this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord - 1 ) instanceof TileController && this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord + 1 ) instanceof TileController;
// int meta = world.getBlockMetadata( xCoord, yCoord, zCoord );
// boolean hasPower = meta > 0;
@@ -134,11 +80,11 @@ public class TileController extends AENetworkPowerTile
boolean oldValid = this.isValid;
this.isValid = (xx && !yy && !zz) || (!xx && yy && !zz) || (!xx && !yy && zz) || ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) <= 1);
this.isValid = ( xx && !yy && !zz ) || ( !xx && yy && !zz ) || ( !xx && !yy && zz ) || ( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) <= 1 );
if ( oldValid != this.isValid || force )
if( oldValid != this.isValid || force )
{
if ( this.isValid )
if( this.isValid )
this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
else
this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
@@ -149,22 +95,22 @@ public class TileController extends AENetworkPowerTile
private void updateMeta()
{
if ( !this.gridProxy.isReady() )
if( !this.gridProxy.isReady() )
return;
int meta = 0;
try
{
if ( this.gridProxy.getEnergy().isNetworkPowered() )
if( this.gridProxy.getEnergy().isNetworkPowered() )
{
meta = 1;
if ( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
if( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
meta = 2;
}
}
catch (GridAccessException e)
catch( GridAccessException e )
{
meta = 0;
}
@@ -172,8 +118,61 @@ public class TileController extends AENetworkPowerTile
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, meta, 2 );
}
final int[] sides = new int[] { };
static final AppEngInternalInventory inv = new AppEngInternalInventory( null, 0 );
@Override
protected double getFunnelPowerDemand( double maxReceived )
{
try
{
return this.gridProxy.getEnergy().getEnergyDemand( 8000 );
}
catch( GridAccessException e )
{
// no grid? use local...
return super.getFunnelPowerDemand( maxReceived );
}
}
@Override
protected double funnelPowerIntoStorage( double AEUnits, Actionable mode )
{
try
{
double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode );
if( mode == Actionable.SIMULATE )
return ret;
return 0;
}
catch( GridAccessException e )
{
// no grid? use local...
return super.funnelPowerIntoStorage( AEUnits, mode );
}
}
@Override
protected void PowerEvent( PowerEventType x )
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
}
catch( GridAccessException e )
{
// not ready!
}
}
@MENetworkEventSubscribe
public void onControllerChange( MENetworkControllerChange status )
{
this.updateMeta();
}
@MENetworkEventSubscribe
public void onPowerChange( MENetworkPowerStatusChange status )
{
this.updateMeta();
}
@Override
public IInventory getInternalInventory()
@@ -182,15 +181,14 @@ public class TileController extends AENetworkPowerTile
}
@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 )
{
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection side)
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
return this.sides;
}
}
@@ -18,6 +18,7 @@
package appeng.tile.networking;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.AccessRestriction;
@@ -27,31 +28,27 @@ import appeng.api.networking.energy.IAEPowerStorage;
import appeng.api.util.AECableType;
import appeng.tile.grid.AENetworkTile;
public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage
{
public TileCreativeEnergyCell() {
public TileCreativeEnergyCell()
{
this.gridProxy.setIdlePowerUsage( 0 );
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.COVERED;
}
@Override
public double injectAEPower(double amt, Actionable mode)
public double injectAEPower( double amt, Actionable mode )
{
return 0;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
{
return amt;
}
@Override
public double getAEMaxPower()
{
@@ -76,4 +73,9 @@ public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerSto
return AccessRestriction.READ_WRITE;
}
@Override
public double extractAEPower( double amt, Actionable mode, PowerMultiplier pm )
{
return amt;
}
}
@@ -18,11 +18,12 @@
package appeng.tile.networking;
public class TileDenseEnergyCell extends TileEnergyCell
{
public TileDenseEnergyCell() {
public TileDenseEnergyCell()
{
this.internalMaxPower = 200000 * 8;
}
}
@@ -37,7 +37,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
{
final static AppEngInternalInventory INTERNAL_INVENTORY = new AppEngInternalInventory( null, 0 );
final int[] sides = new int[] { };
final int[] sides = new int[] {};
public TileEnergyAcceptor()
{
@@ -45,12 +45,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
this.internalMaxPower = 0;
}
@Override
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.COVERED;
}
@Override
public void readFromNBT_AENetwork( NBTTagCompound data )
{
@@ -67,6 +61,12 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
*/
}
@Override
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.COVERED;
}
@Override
protected double getFunnelPowerDemand( double maxRequired )
{
@@ -75,7 +75,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
IEnergyGrid grid = this.gridProxy.getEnergy();
return grid.getEnergyDemand( maxRequired );
}
catch ( GridAccessException e )
catch( GridAccessException e )
{
return this.internalMaxPower;
}
@@ -88,11 +88,11 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
{
IEnergyGrid grid = this.gridProxy.getEnergy();
double leftOver = grid.injectPower( newPower, mode );
if ( mode == Actionable.SIMULATE )
if( mode == Actionable.SIMULATE )
return leftOver;
return 0.0;
}
catch ( GridAccessException e )
catch( GridAccessException e )
{
return super.funnelPowerIntoStorage( newPower, mode );
}
@@ -18,6 +18,7 @@
package appeng.tile.networking;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
@@ -34,6 +35,7 @@ import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
import appeng.util.SettingsFrom;
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
{
@@ -42,48 +44,57 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
private byte currentMeta = -1;
public TileEnergyCell()
{
this.gridProxy.setIdlePowerUsage( 0 );
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
public AECableType getCableConnectionType( ForgeDirection dir )
{
return AECableType.COVERED;
}
@Override
public void onReady()
{
super.onReady();
this.currentMeta = (byte) this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
this.changePowerLevel();
}
private void changePowerLevel()
{
if ( this.notLoaded() )
if( this.notLoaded() )
return;
byte boundMetadata = (byte) (8.0 * (this.internalCurrentPower / this.internalMaxPower));
byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.internalMaxPower ) );
if ( boundMetadata > 7 )
if( boundMetadata > 7 )
boundMetadata = 7;
if ( boundMetadata < 0 )
if( boundMetadata < 0 )
boundMetadata = 0;
if ( this.currentMeta != boundMetadata )
if( this.currentMeta != boundMetadata )
{
this.currentMeta = boundMetadata;
this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, this.currentMeta, 2 );
}
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeToNBT_TileEnergyCell(NBTTagCompound data)
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public void writeToNBT_TileEnergyCell( NBTTagCompound data )
{
if ( !this.worldObj.isRemote )
if( !this.worldObj.isRemote )
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBT_TileEnergyCell(NBTTagCompound data)
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBT_TileEnergyCell( NBTTagCompound data )
{
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
}
public TileEnergyCell() {
this.gridProxy.setIdlePowerUsage( 0 );
}
@Override
public boolean canBeRotated()
{
@@ -91,12 +102,34 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
}
@Override
final public double injectAEPower(double amt, Actionable mode)
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )
{
if ( mode == Actionable.SIMULATE )
if( from == SettingsFrom.DISMANTLE_ITEM )
{
this.internalCurrentPower = compound.getDouble( "internalCurrentPower" );
}
}
@Override
public NBTTagCompound downloadSettings( SettingsFrom from )
{
if( from == SettingsFrom.DISMANTLE_ITEM )
{
NBTTagCompound tag = new NBTTagCompound();
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
tag.setDouble( "internalMaxPower", this.internalMaxPower ); // used for tool tip.
return tag;
}
return null;
}
@Override
final public double injectAEPower( double amt, Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
double fakeBattery = this.internalCurrentPower + amt;
if ( fakeBattery > this.internalMaxPower )
if( fakeBattery > this.internalMaxPower )
{
return fakeBattery - this.internalMaxPower;
}
@@ -104,11 +137,11 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
return 0;
}
if ( this.internalCurrentPower < 0.01 && amt > 0.01 )
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
this.gridProxy.getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
this.internalCurrentPower += amt;
if ( this.internalCurrentPower > this.internalMaxPower )
if( this.internalCurrentPower > this.internalMaxPower )
{
amt = this.internalCurrentPower - this.internalMaxPower;
this.internalCurrentPower = this.internalMaxPower;
@@ -121,50 +154,6 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
return 0;
}
private double extractAEPower(double amt, Actionable mode)
{
if ( mode == Actionable.SIMULATE )
{
if ( this.internalCurrentPower > amt )
return amt;
return this.internalCurrentPower;
}
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
if ( wasFull && amt > 0.001 )
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
}
catch (GridAccessException ignored)
{
}
}
if ( this.internalCurrentPower > amt )
{
this.internalCurrentPower -= amt;
this.changePowerLevel();
return amt;
}
amt = this.internalCurrentPower;
this.internalCurrentPower = 0;
this.changePowerLevel();
return amt;
}
@Override
final public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
{
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) );
}
@Override
public double getAEMaxPower()
{
@@ -190,32 +179,46 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
}
@Override
public void onReady()
final public double extractAEPower( double amt, Actionable mode, PowerMultiplier pm )
{
super.onReady();
this.currentMeta = (byte) this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord );
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) );
}
private double extractAEPower( double amt, Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
if( this.internalCurrentPower > amt )
return amt;
return this.internalCurrentPower;
}
boolean wasFull = this.internalCurrentPower >= this.internalMaxPower - 0.001;
if( wasFull && amt > 0.001 )
{
try
{
this.gridProxy.getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
}
catch( GridAccessException ignored )
{
}
}
if( this.internalCurrentPower > amt )
{
this.internalCurrentPower -= amt;
this.changePowerLevel();
return amt;
}
amt = this.internalCurrentPower;
this.internalCurrentPower = 0;
this.changePowerLevel();
}
@Override
public NBTTagCompound downloadSettings(SettingsFrom from)
{
if ( from == SettingsFrom.DISMANTLE_ITEM )
{
NBTTagCompound tag = new NBTTagCompound();
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
tag.setDouble( "internalMaxPower", this.internalMaxPower ); // used for tool tip.
return tag;
}
return null;
}
@Override
public void uploadSettings(SettingsFrom from, NBTTagCompound compound)
{
if ( from == SettingsFrom.DISMANTLE_ITEM )
{
this.internalCurrentPower = compound.getDouble( "internalCurrentPower" );
}
return amt;
}
}
@@ -1,4 +1,3 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
@@ -100,18 +99,18 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
try
{
if ( this.gridProxy.getEnergy().isNetworkPowered() )
if( this.gridProxy.getEnergy().isNetworkPowered() )
this.clientFlags |= POWERED_FLAG;
if ( this.gridProxy.getNode().meetsChannelRequirements() )
if( this.gridProxy.getNode().meetsChannelRequirements() )
this.clientFlags |= CHANNEL_FLAG;
}
catch ( GridAccessException e )
catch( GridAccessException e )
{
// meh
}
data.writeByte( ( byte ) this.clientFlags );
data.writeByte( (byte) this.clientFlags );
}
@Override
@@ -132,64 +131,6 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
return this.inv;
}
@Override
public void onReady()
{
this.updatePower();
super.onReady();
}
@Override
public void markDirty()
{
this.updatePower();
}
private void updatePower()
{
this.gridProxy.setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
}
@Override
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
return this.sides;
}
@Override
public double getRange()
{
return AEConfig.instance.wireless_getMaxRange( this.getBoosters() );
}
@Override
public boolean isActive()
{
if ( Platform.isClient() )
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
return this.gridProxy.isActive();
}
@Override
public IGrid getGrid()
{
try
{
return this.gridProxy.getGrid();
}
catch ( GridAccessException e )
{
return null;
}
}
private int getBoosters()
{
ItemStack boosters = this.inv.getStackInSlot( 0 );
return boosters == null ? 0 : boosters.stackSize;
}
@Override
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
@@ -202,10 +143,67 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
// :P
}
@Override
public int[] getAccessibleSlotsBySide( ForgeDirection side )
{
return this.sides;
}
@Override
public void onReady()
{
this.updatePower();
super.onReady();
}
private void updatePower()
{
this.gridProxy.setIdlePowerUsage( AEConfig.instance.wireless_getPowerDrain( this.getBoosters() ) );
}
private int getBoosters()
{
ItemStack boosters = this.inv.getStackInSlot( 0 );
return boosters == null ? 0 : boosters.stackSize;
}
@Override
public void markDirty()
{
this.updatePower();
}
@Override
public double getRange()
{
return AEConfig.instance.wireless_getMaxRange( this.getBoosters() );
}
@Override
public boolean isActive()
{
if( Platform.isClient() )
return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) );
return this.gridProxy.isActive();
}
@Override
public IGrid getGrid()
{
try
{
return this.gridProxy.getGrid();
}
catch( GridAccessException e )
{
return null;
}
}
@Override
public boolean isPowered()
{
return POWERED_FLAG == ( this.clientFlags & POWERED_FLAG );
}
}