Implemented dynamic crane rail connection

This commit is contained in:
Brian Ricketts 2013-02-11 12:03:54 -06:00
parent 84a67a2e9a
commit 72bdd69060
4 changed files with 51 additions and 2 deletions

View file

@ -20,9 +20,35 @@ public class CraneHelper
{
if (tileEntity.worldObj.getBlockTileEntity(x, y, z) != null && tileEntity.worldObj.getBlockTileEntity(x, y, z) instanceof ICraneConnectable)
{
return true;
return ((ICraneConnectable) tileEntity.worldObj.getBlockTileEntity(x, y, z)).canFrameConnectTo(side);
}
return false;
}
public static ForgeDirection rotateClockwise(ForgeDirection direction)
{
if (direction == ForgeDirection.NORTH)
return ForgeDirection.EAST;
if (direction == ForgeDirection.EAST)
return ForgeDirection.SOUTH;
if (direction == ForgeDirection.SOUTH)
return ForgeDirection.WEST;
if (direction == ForgeDirection.WEST)
return ForgeDirection.NORTH;
return ForgeDirection.UNKNOWN;
}
public static ForgeDirection rotateCounterClockwise(ForgeDirection direction)
{
if (direction == ForgeDirection.NORTH)
return ForgeDirection.WEST;
if (direction == ForgeDirection.WEST)
return ForgeDirection.SOUTH;
if (direction == ForgeDirection.SOUTH)
return ForgeDirection.EAST;
if (direction == ForgeDirection.EAST)
return ForgeDirection.NORTH;
return ForgeDirection.UNKNOWN;
}
}

View file

@ -1,6 +1,8 @@
package assemblyline.common.machine.crane;
import net.minecraftforge.common.ForgeDirection;
public interface ICraneConnectable
{
boolean canFrameConnectTo(ForgeDirection side);
}

View file

@ -1,5 +1,6 @@
package assemblyline.common.machine.crane;
import net.minecraftforge.common.ForgeDirection;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
public class TileEntityCraneController extends TileEntityAssemblyNetwork implements ICraneConnectable
@ -9,4 +10,17 @@ public class TileEntityCraneController extends TileEntityAssemblyNetwork impleme
{
}
@Override
public boolean canFrameConnectTo(ForgeDirection side)
{
ForgeDirection facing = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
if (side == facing)
return true;
if (side == CraneHelper.rotateClockwise(facing))
return true;
if (side == ForgeDirection.UP)
return true;
return false;
}
}

View file

@ -1,8 +1,15 @@
package assemblyline.common.machine.crane;
import net.minecraftforge.common.ForgeDirection;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
public class TileEntityCraneRail extends TileEntityAssemblyNetwork implements ICraneConnectable
{
@Override
public boolean canFrameConnectTo(ForgeDirection side)
{
return true;
}
}