From 84f2a90c02e14e179ab893a26f5a697dce9d0464 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Tue, 28 Jan 2014 14:46:38 +0800 Subject: [PATCH] Fixed gear shaft inverting rotation --- .../java/resonantinduction/mechanical/gear/PartGear.java | 4 ++-- .../resonantinduction/mechanical/gear/PartGearShaft.java | 7 ++++--- .../resonantinduction/mechanical/network/IMechanical.java | 2 +- .../mechanical/network/MechanicalNetwork.java | 2 +- .../mechanical/network/TileMechanical.java | 2 +- .../mechanical/trait/TraitMechanical.java | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/resonantinduction/mechanical/gear/PartGear.java b/src/main/java/resonantinduction/mechanical/gear/PartGear.java index 58ae3bc63..c236e55af 100644 --- a/src/main/java/resonantinduction/mechanical/gear/PartGear.java +++ b/src/main/java/resonantinduction/mechanical/gear/PartGear.java @@ -461,8 +461,8 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock } @Override - public boolean inverseRotation(ForgeDirection dir) + public boolean inverseRotation(ForgeDirection dir, IMechanical with) { - return dir != placementSide.getOpposite(); + return !(with instanceof PartGearShaft); } } \ No newline at end of file diff --git a/src/main/java/resonantinduction/mechanical/gear/PartGearShaft.java b/src/main/java/resonantinduction/mechanical/gear/PartGearShaft.java index 613bfc41b..9eedf992e 100644 --- a/src/main/java/resonantinduction/mechanical/gear/PartGearShaft.java +++ b/src/main/java/resonantinduction/mechanical/gear/PartGearShaft.java @@ -93,7 +93,8 @@ public class PartGearShaft extends PartMechanical { IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(checkDir.getOpposite()); - if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this)) + // Only connet to shafts outside of this block space. + if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && instance instanceof PartGearShaft) { connections[checkDir.ordinal()] = instance; getNetwork().merge(instance.getNetwork()); @@ -155,9 +156,9 @@ public class PartGearShaft extends PartMechanical } @Override - public boolean inverseRotation(ForgeDirection dir) + public boolean inverseRotation(ForgeDirection dir, IMechanical with) { - return dir == placementSide; + return dir == placementSide.getOpposite() && !(with instanceof PartGearShaft); } } \ No newline at end of file diff --git a/src/main/java/resonantinduction/mechanical/network/IMechanical.java b/src/main/java/resonantinduction/mechanical/network/IMechanical.java index 86d3c7e9d..97dea6f61 100644 --- a/src/main/java/resonantinduction/mechanical/network/IMechanical.java +++ b/src/main/java/resonantinduction/mechanical/network/IMechanical.java @@ -21,7 +21,7 @@ public interface IMechanical extends IConnector public float getRatio(ForgeDirection dir); - public boolean inverseRotation(ForgeDirection dir); + public boolean inverseRotation(ForgeDirection dir, IMechanical with); public IMechanical getInstance(ForgeDirection dir); diff --git a/src/main/java/resonantinduction/mechanical/network/MechanicalNetwork.java b/src/main/java/resonantinduction/mechanical/network/MechanicalNetwork.java index 46994b974..484c847a6 100644 --- a/src/main/java/resonantinduction/mechanical/network/MechanicalNetwork.java +++ b/src/main/java/resonantinduction/mechanical/network/MechanicalNetwork.java @@ -80,7 +80,7 @@ public class MechanicalNetwork extends Network float ratio = adjacentMech.getRatio(dir) / mechanical.getRatio(dir.getOpposite()); long torque = mechanical.getTorque(); - boolean inverseRotation = mechanical.inverseRotation(dir) && adjacentMech.inverseRotation(dir.getOpposite()); + boolean inverseRotation = mechanical.inverseRotation(dir, adjacentMech)|| adjacentMech.inverseRotation(dir.getOpposite(), mechanical); int inversion = inverseRotation ? -1 : 1; diff --git a/src/main/java/resonantinduction/mechanical/network/TileMechanical.java b/src/main/java/resonantinduction/mechanical/network/TileMechanical.java index 749e0d119..8bfde6b17 100644 --- a/src/main/java/resonantinduction/mechanical/network/TileMechanical.java +++ b/src/main/java/resonantinduction/mechanical/network/TileMechanical.java @@ -140,7 +140,7 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical } @Override - public boolean inverseRotation(ForgeDirection dir) + public boolean inverseRotation(ForgeDirection dir, IMechanical with) { return true; } diff --git a/src/main/java/resonantinduction/mechanical/trait/TraitMechanical.java b/src/main/java/resonantinduction/mechanical/trait/TraitMechanical.java index a29dc6dbc..ec26529fe 100644 --- a/src/main/java/resonantinduction/mechanical/trait/TraitMechanical.java +++ b/src/main/java/resonantinduction/mechanical/trait/TraitMechanical.java @@ -144,7 +144,7 @@ public class TraitMechanical extends TileMultipart implements IMechanical } @Override - public boolean inverseRotation(ForgeDirection dir) + public boolean inverseRotation(ForgeDirection dir, IMechanical with) { return false; }