Implemented dynamic crane rail connection
This commit is contained in:
parent
84a67a2e9a
commit
72bdd69060
4 changed files with 51 additions and 2 deletions
|
@ -20,9 +20,35 @@ public class CraneHelper
|
||||||
{
|
{
|
||||||
if (tileEntity.worldObj.getBlockTileEntity(x, y, z) != null && tileEntity.worldObj.getBlockTileEntity(x, y, z) instanceof ICraneConnectable)
|
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;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package assemblyline.common.machine.crane;
|
package assemblyline.common.machine.crane;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
public interface ICraneConnectable
|
public interface ICraneConnectable
|
||||||
{
|
{
|
||||||
|
boolean canFrameConnectTo(ForgeDirection side);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package assemblyline.common.machine.crane;
|
package assemblyline.common.machine.crane;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import assemblyline.common.machine.TileEntityAssemblyNetwork;
|
import assemblyline.common.machine.TileEntityAssemblyNetwork;
|
||||||
|
|
||||||
public class TileEntityCraneController extends TileEntityAssemblyNetwork implements ICraneConnectable
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
package assemblyline.common.machine.crane;
|
package assemblyline.common.machine.crane;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import assemblyline.common.machine.TileEntityAssemblyNetwork;
|
import assemblyline.common.machine.TileEntityAssemblyNetwork;
|
||||||
|
|
||||||
public class TileEntityCraneRail extends TileEntityAssemblyNetwork implements ICraneConnectable
|
public class TileEntityCraneRail extends TileEntityAssemblyNetwork implements ICraneConnectable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFrameConnectTo(ForgeDirection side)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue