From 055bbf4b8247a9ba04ef588c6c133b4f0d91638e Mon Sep 17 00:00:00 2001 From: Robert S Date: Thu, 5 Jun 2014 01:08:47 -0400 Subject: [PATCH] Cleaned up debug messages making them easier to read --- .../electrical/generator/TileMotor.java | 8 +++++- .../energy/grid/MechanicalNode.java | 26 ++++++++++++------- .../energy/grid/PartMechanical.java | 2 +- .../mechanical/gear/GearNode.java | 2 +- .../mechanical/gear/PartGear.java | 4 +-- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/electrical/src/main/scala/resonantinduction/electrical/generator/TileMotor.java b/electrical/src/main/scala/resonantinduction/electrical/generator/TileMotor.java index cdbe99d92..6af830255 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/generator/TileMotor.java +++ b/electrical/src/main/scala/resonantinduction/electrical/generator/TileMotor.java @@ -61,7 +61,7 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid if (node != null) { - node.update(0.05f); + node.update(0.05f); if (!isInversed) { receiveMechanical(); @@ -174,4 +174,10 @@ public class TileMotor extends TileElectrical implements IRotatable, INodeProvid return null; } + + @Override + public String toString() + { + return "[TileMotor]" + x() + "x " + y() + "y " + z() + "z "; + } } 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 5beaf1c5a..655ca5aab 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/MechanicalNode.java @@ -65,19 +65,22 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj public void debug(String txt) { - if (doDebug) - System.out.println("[MechMode]" + txt); + debug(txt, false); + } + + public void debug(String txt, boolean nextLine) + { + if (doDebug && world() != null && !world().isRemote) + System.out.println((nextLine ? "\n" : "") + "[MechMode]" + txt); } @Override public void update(float deltaTime) { + debug("Node->Update"); prevAngularVelocity = angularVelocity; - if (world() != null && !world().isRemote) - debug("Node :" + toString()); + debug("\tNode :" + toString()); //Update - if (world() != null && !world().isRemote) - debug("AngleBefore: " + renderAngle + " Vel: " + angularVelocity); if (angularVelocity >= 0) { renderAngle += Math.min(angularVelocity, this.maxDeltaAngle) * deltaTime; @@ -86,8 +89,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj { renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime; } - if (world() != null && !world().isRemote) - debug("AngleAfter: " + renderAngle + " Vel: " + angularVelocity); + debug("\tAngle: " + renderAngle + " Vel: " + angularVelocity); if (renderAngle % (Math.PI * 2) != renderAngle) { @@ -129,6 +131,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj power = getEnergy() / deltaTime; + debug("Node->Connections"); synchronized (connections) { Iterator> it = connections.entrySet().iterator(); @@ -139,7 +142,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj ForgeDirection dir = entry.getValue(); MechanicalNode adjacentMech = entry.getKey(); - debug("Connection: " + adjacentMech + " Side: " + dir); + debug("\tConnection: " + adjacentMech + " Side: " + dir); /** Calculate angular velocity and torque. */ float ratio = adjacentMech.getRatio(dir.getOpposite(), this) / getRatio(dir, adjacentMech); boolean inverseRotation = inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), this); @@ -321,4 +324,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj this.parent = parent; } + @Override + public String toString() + { + return this.getClass().getName() + this.hashCode(); + } } 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 a26e720ee..8abb36dc2 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/energy/grid/PartMechanical.java @@ -50,7 +50,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu if (!world().isRemote) { checkClientUpdate(); - System.out.println("\nPart: " + this + " Node: " + this.node); + node.debug("Part: " + this + " Node: " + this.node); this.node.update(0.05f); } diff --git a/mechanical/src/main/scala/resonantinduction/mechanical/gear/GearNode.java b/mechanical/src/main/scala/resonantinduction/mechanical/gear/GearNode.java index 0c2dd4467..db61b8739 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/gear/GearNode.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/gear/GearNode.java @@ -81,7 +81,7 @@ public class GearNode extends MechanicalNode @Override public void recache() { - System.out.println("doRecache: " + this); + debug("doRecache: " + this); connections.clear(); /** Only call refresh if this is the main block of a multiblock gear or a single gear block. */ diff --git a/mechanical/src/main/scala/resonantinduction/mechanical/gear/PartGear.java b/mechanical/src/main/scala/resonantinduction/mechanical/gear/PartGear.java index ab0952445..79bbae3af 100644 --- a/mechanical/src/main/scala/resonantinduction/mechanical/gear/PartGear.java +++ b/mechanical/src/main/scala/resonantinduction/mechanical/gear/PartGear.java @@ -70,12 +70,10 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure>>" + this.node); - this.node.update(0.05f); if (manualCrankTime > 0) { node.apply(this, isClockwiseCrank ? 15 : -15, isClockwiseCrank ? 0.025f : -0.025f); - manualCrankTime--; + //manualCrankTime--; } } getMultiBlock().update();