Fixed shaft connections

This commit is contained in:
Calclavia 2014-11-26 23:13:49 +08:00
parent 5487528ac3
commit 87be8ec6e8
2 changed files with 8 additions and 7 deletions

View file

@ -64,7 +64,7 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
//Check internal
for (i <- 0 until 6)
{
val toDir = if (ForgeDirection.getOrientation(i) == gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else ForgeDirection.getOrientation(i)
val toDir = ForgeDirection.getOrientation(i)
var tile: TileEntity = gear.tile
if (gear.getMultiBlock.isConstructed && toDir != gear.placementSide && toDir != gear.placementSide.getOpposite)
@ -74,7 +74,7 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
if (tile.isInstanceOf[INodeProvider])
{
val other = tile.asInstanceOf[INodeProvider].getNode(classOf[NodeMechanical], toDir)
val other = tile.asInstanceOf[INodeProvider].getNode(classOf[NodeMechanical], if (toDir == gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else toDir)
if (other != this && toDir != gear.placementSide && other != null && canConnect(other, toDir) && other.canConnect(this, toDir.getOpposite))
{
@ -193,7 +193,7 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
//We are connecting to a shaft.
val shaft = otherParent.asInstanceOf[PartGearShaft]
/*shaft.tile.partMap(from.getOpposite.ordinal) != gear && */
return Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
return Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
}
}
else if (from != ForgeDirection.UNKNOWN)

View file

@ -43,9 +43,9 @@ class NodeGearShaft(parent: PartGearShaft) extends NodeMechanical(parent)
if (checkTile.isInstanceOf[INodeProvider])
{
val instance = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], toDir.getOpposite)
val instance = checkTile.asInstanceOf[INodeProvider].getNode(classOf[NodeMechanical], toDir.getOpposite)
if (instance != null && instance != this && instance.getParent.isInstanceOf[PartGearShaft] && instance.canConnect(this, toDir.getOpposite))
if (instance != null && instance != this && instance.getParent.isInstanceOf[PartGearShaft] && canConnect(instance, toDir) && instance.canConnect(this, toDir.getOpposite))
{
connect(instance, toDir)
}
@ -58,15 +58,16 @@ class NodeGearShaft(parent: PartGearShaft) extends NodeMechanical(parent)
{
if (other.isInstanceOf[NodeMechanical])
{
if ((other.asInstanceOf[NodeMechanical]).getParent.isInstanceOf[PartGear])
if (other.asInstanceOf[NodeMechanical].getParent.isInstanceOf[PartGear])
{
val gear: PartGear = (other.asInstanceOf[NodeMechanical]).getParent.asInstanceOf[PartGear]
val gear = other.asInstanceOf[NodeMechanical].getParent.asInstanceOf[PartGear]
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(shaft.placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(shaft.placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(shaft.placementSide.offsetZ)))
{
return false
}
}
}
return from == shaft.placementSide || from == shaft.placementSide.getOpposite
}