Little cleanup and removal of debug

This commit is contained in:
Robert S 2014-06-07 04:59:58 -04:00
parent 92b047741e
commit 4fbbdd101b

View file

@ -31,6 +31,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
/** Packets */ /** Packets */
int ticks = 0; int ticks = 0;
boolean markPacketUpdate = false; boolean markPacketUpdate = false;
/** Simple debug external GUI */
GearDebugFrame frame = null;
/** Side of the block this is placed on */ /** Side of the block this is placed on */
public ForgeDirection placementSide = ForgeDirection.UNKNOWN; public ForgeDirection placementSide = ForgeDirection.UNKNOWN;
@ -47,13 +49,20 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
public void update() public void update()
{ {
ticks++; ticks++;
if (ticks >= Long.MAX_VALUE)
{
ticks = 0;
}
if (!world().isRemote) if (!world().isRemote)
{ {
checkClientUpdate(); checkClientUpdate();
node.debug("Part: " + this + " Node: " + this.node);
this.node.update(0.05f); this.node.update(0.05f);
} }
else
{
//System.out.println("Client->[" + this + "]Angle: " + node.renderAngle);
}
if (frame != null) if (frame != null)
{ {
frame.update(); frame.update();
@ -61,27 +70,17 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
super.update(); super.update();
} }
GearDebugFrame frame = null;
@Override @Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack) public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack)
{ {
if (ResonantEngine.runningAsDev) if (ResonantEngine.runningAsDev)
{ {
if (itemStack != null) if (itemStack != null && !world().isRemote)
{
if (!world().isRemote)
{ {
if (itemStack.getItem().itemID == Item.stick.itemID) if (itemStack.getItem().itemID == Item.stick.itemID)
{ {
//Set the nodes debug mode //Set the nodes debug mode
if (!ControlKeyModifer.isControlDown(player)) if (ControlKeyModifer.isControlDown(player))
{
this.node.doDebug = !this.node.doDebug;
player.addChatMessage("[Debug] PartMechanical debug mode is now " + (this.node.doDebug ? "on" : "off"));
}
else
{ {
//Opens a debug GUI //Opens a debug GUI
if (frame == null) if (frame == null)
@ -95,36 +94,6 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
frame = null; frame = null;
} }
} }
}//Changes the debug cue of the node
else if (itemStack.getItem().itemID == Item.blazeRod.itemID)
{
if (this.node.doDebug)
{
//Increases the cue count
if (!ControlKeyModifer.isControlDown(player))
{
if (this.node.debugCue + 1 <= this.node.maxDebugCue)
this.node.debugCue++;
else
{
player.addChatMessage("[Debug] PartMechanical is at max debug cue");
}
}//Decreases the cue count
else
{
if (this.node.debugCue - 1 >= this.node.minDebugCue)
this.node.debugCue--;
else
{
player.addChatMessage("[Debug] PartMechanical is at min debug cue");
}
}
player.addChatMessage("[Debug] PartMechanical debug due is now " + this.node.debugCue);
}
}
} }
} }
} }
@ -133,16 +102,10 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
public void checkClientUpdate() public void checkClientUpdate()
{ {
if (Math.abs(prevAngularVelocity - node.angularVelocity) > 0.001f || (prevAngularVelocity != node.angularVelocity && (prevAngularVelocity == 0 || node.angularVelocity == 0))) if (Math.abs(prevAngularVelocity - node.angularVelocity) >= 0.1)
{ {
prevAngularVelocity = node.angularVelocity; prevAngularVelocity = node.angularVelocity;
markPacketUpdate = true;
}
if (markPacketUpdate && ticks % 10 == 0)
{
sendRotationPacket(); sendRotationPacket();
markPacketUpdate = false;
} }
} }