Applied-Energistics-2-tiler.../tile/powersink/RotaryCraft.java

152 lines
2.6 KiB
Java
Raw Normal View History

package appeng.tile.powersink;
2014-02-09 02:34:52 +01:00
import net.minecraftforge.common.util.ForgeDirection;
import Reika.RotaryCraft.API.ShaftPowerReceiver;
import appeng.api.config.PowerUnits;
2013-12-30 06:55:15 +01:00
import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
import appeng.util.Platform;
import cpw.mods.fml.common.Optional.Interface;
@Interface(modid = "RotaryCraft", iface = "Reika.RotaryCraft.API.ShaftPowerReceiver")
public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
{
private int omega = 0;
private int torque = 0;
private long power = 0;
private int alpha = 0;
2013-12-30 06:55:15 +01:00
class RotaryCraftHandler extends AETileEventHandler
{
public RotaryCraftHandler() {
2014-01-26 07:46:16 +01:00
super( TileEventType.TICK );
2013-12-30 06:55:15 +01:00
}
@Override
public void Tick()
{
if ( power > 0 )
injectExternalPower( PowerUnits.WA, power );
2013-12-30 06:55:15 +01:00
}
};
public RotaryCraft() {
if ( Platform.isServer() )
addNewHandler( new RotaryCraftHandler() );
2013-12-30 06:55:15 +01:00
}
@Override
final public int getOmega()
{
return omega;
}
@Override
final public int getTorque()
{
return torque;
}
@Override
final public long getPower()
{
return power;
}
@Override
final public String getName()
{
return "AE";
}
@Override
final public int getIORenderAlpha()
{
return alpha;
}
@Override
final public void setIORenderAlpha(int io)
{
alpha = io;
}
@Override
final public int getMachineX()
{
return xCoord;
}
@Override
final public int getMachineY()
{
return yCoord;
}
@Override
final public int getMachineZ()
{
return zCoord;
}
@Override
final public void setOmega(int o)
{
omega = o;
}
@Override
final public void setTorque(int t)
{
torque = t;
}
@Override
final public void setPower(long p)
{
2013-12-30 06:55:15 +01:00
if ( Platform.isClient() )
return;
power = p;
}
@Override
final public boolean canReadFromBlock(int x, int y, int z)
{
ForgeDirection side = ForgeDirection.UNKNOWN;
if ( x == xCoord - 1 )
side = ForgeDirection.WEST;
else if ( x == xCoord + 1 )
side = ForgeDirection.EAST;
else if ( z == zCoord - 1 )
side = ForgeDirection.NORTH;
else if ( z == zCoord + 1 )
side = ForgeDirection.SOUTH;
else if ( y == yCoord - 1 )
side = ForgeDirection.DOWN;
else if ( y == yCoord + 1 )
side = ForgeDirection.UP;
return internalCanAcceptPower && getPowerSides().contains( side );
}
@Override
final public boolean isReceiving()
{
return true;
}
@Override
final public void noInputMachine()
{
power = 0;
torque = 0;
omega = 0;
}
}