diff --git a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java index d9dad5181..5b53f22ef 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java @@ -13,6 +13,7 @@ import resonant.api.grid.INode; import resonant.api.grid.INodeProvider; import resonant.lib.utility.nbt.ISaveObj; import resonantinduction.core.interfaces.IMechanicalNode; +import universalelectricity.api.vector.IVectorWorld; import universalelectricity.api.vector.Vector3; import codechicken.multipart.TMultiPart; @@ -31,7 +32,7 @@ import codechicken.multipart.TMultiPart; * can be added by extending the gui. * * @author Calclavia, Darkguardsman */ -public class MechanicalNode implements IMechanicalNode, ISaveObj +public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld { /** Is debug enabled for the node */ public boolean doDebug = false; @@ -261,15 +262,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj return load; } - public World world() - { - return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null; - } - - public Vector3 position() - { - return getParent() instanceof TMultiPart ? new Vector3(((TMultiPart) getParent()).x(), ((TMultiPart) getParent()).y(), ((TMultiPart) getParent()).z()) : getParent() instanceof TileEntity ? new Vector3((TileEntity) getParent()) : null; - } + /** Checks to see if a connection is allowed from side and from a source */ public boolean canConnect(ForgeDirection from, Object source) @@ -319,6 +312,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj { for (Entry entry : getConnections().entrySet()) { + entry.getKey().getConnections().remove(this); entry.getKey().recache(); } getConnections().clear(); @@ -371,4 +365,33 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj { return connections; } + + @Override + public World world() + { + return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null; + } + + public Vector3 position() + { + return new Vector3(x(), y(), z()); + } + + @Override + public double z() + { + return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).z() : 0; + } + + @Override + public double x() + { + return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).x() : 0; + } + + @Override + public double y() + { + return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).y() : 0; + } } diff --git a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java index eba5e9258..d57fa8ae8 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java @@ -25,11 +25,11 @@ import codechicken.multipart.TFacePart; * @author Calclavia */ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclusion, TFacePart, INodeProvider { + /** Node that handles mechanical action of the machine */ public MechanicalNode node; - protected double prevAngularVelocity; - - /** Packets */ + protected double prevAngularVelocity; int ticks = 0; + /** Packets */ boolean markPacketUpdate = false; /** Simple debug external GUI */ GearDebugFrame frame = null; @@ -53,15 +53,17 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu { ticks = 0; } - + + //Make sure to update on both sides + this.node.update(0.05f); + if (!world().isRemote) { - checkClientUpdate(); - this.node.update(0.05f); + checkClientUpdate(); } else { - //System.out.println("Client->[" + this + "]Angle: " + node.renderAngle); + System.out.println("Client->[" + this + "]Angle: " + node.renderAngle); } if (frame != null) {