2013-12-27 23:59:59 +01:00
|
|
|
package appeng.tile.powersink;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
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;
|
2014-04-06 08:55:24 +02:00
|
|
|
import appeng.transformer.annotations.integration.Interface;
|
2013-12-30 06:55:15 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-04-06 08:55:24 +02:00
|
|
|
@Interface(iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.ShaftPowerReceiver")
|
2013-12-27 23:59:59 +01:00
|
|
|
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()
|
|
|
|
{
|
2014-01-24 17:34:03 +01:00
|
|
|
if ( power > 0 )
|
|
|
|
injectExternalPower( PowerUnits.WA, power );
|
2013-12-30 06:55:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
public RotaryCraft() {
|
2014-01-01 10:03:31 +01:00
|
|
|
if ( Platform.isServer() )
|
|
|
|
addNewHandler( new RotaryCraftHandler() );
|
2013-12-30 06:55:15 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +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;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|