Moved Turbine node to its own class

This commit is contained in:
Robert S 2014-06-07 07:10:52 -04:00
parent 898f471c7a
commit 72b268611a

View file

@ -0,0 +1,53 @@
package resonantinduction.mechanical.energy.turbine;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import resonant.api.grid.INodeProvider;
import resonantinduction.core.interfaces.IMechanicalNode;
import resonantinduction.mechanical.energy.grid.MechanicalNode;
/** Turbine's Mechanical node
*
* @author Calclavia, Darkguardsman */
public class TurbineNode extends MechanicalNode
{
public TurbineNode(TileMechanicalTurbine parent)
{
super(parent);
}
public TileMechanicalTurbine turbine()
{
return (TileMechanicalTurbine) getParent();
}
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if (source instanceof MechanicalNode && !(source instanceof TileMechanicalTurbine))
{
/** Face to face stick connection. */
TileEntity sourceTile = position().translate(from).getTileEntity(turbine().getWorld());
if (sourceTile instanceof INodeProvider)
{
MechanicalNode sourceInstance = (MechanicalNode) ((INodeProvider) sourceTile).getNode(MechanicalNode.class, from.getOpposite());
return sourceInstance == source && from == turbine().getDirection().getOpposite();
}
}
return false;
}
@Override
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
{
return dir == turbine().getDirection().getOpposite();
}
@Override
public float getRatio(ForgeDirection dir, IMechanicalNode with)
{
return turbine().getMultiBlock().isConstructed() ? turbine().multiBlockRadius - 0.5f : 0.5f;
}
}