Removed debug as gears mostly work now, only need to fix client sync issue
This commit is contained in:
parent
940681ed82
commit
92b047741e
3 changed files with 5 additions and 43 deletions
|
@ -83,22 +83,6 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(String txt)
|
|
||||||
{
|
|
||||||
debug(txt, UPDATE_DEBUG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug(String txt, int cue)
|
|
||||||
{
|
|
||||||
debug(txt, cue, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug(String txt, int cue, boolean nextLine)
|
|
||||||
{
|
|
||||||
if (doDebug && world() != null && !world().isRemote && cue == debugCue)
|
|
||||||
System.out.println((nextLine ? "\n" : "") + "[MechMode]" + txt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float deltaTime)
|
public void update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
@ -115,9 +99,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Render Update
|
// Render Update
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
debug("Node->Update");
|
|
||||||
prevAngularVelocity = angularVelocity;
|
prevAngularVelocity = angularVelocity;
|
||||||
debug("\tNode :" + toString());
|
|
||||||
|
|
||||||
if (angularVelocity >= 0)
|
if (angularVelocity >= 0)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +109,6 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
{
|
{
|
||||||
renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime;
|
renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime;
|
||||||
}
|
}
|
||||||
debug("\tAngle: " + renderAngle + " Vel: " + angularVelocity);
|
|
||||||
|
|
||||||
if (renderAngle % (Math.PI * 2) != renderAngle)
|
if (renderAngle % (Math.PI * 2) != renderAngle)
|
||||||
{
|
{
|
||||||
|
@ -177,7 +158,6 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
// Connection application of force and speed
|
// Connection application of force and speed
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
debug("Node->Connections");
|
|
||||||
synchronized (getConnections())
|
synchronized (getConnections())
|
||||||
{
|
{
|
||||||
Iterator<Entry<MechanicalNode, ForgeDirection>> it = getConnections().entrySet().iterator();
|
Iterator<Entry<MechanicalNode, ForgeDirection>> it = getConnections().entrySet().iterator();
|
||||||
|
@ -188,7 +168,6 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
|
|
||||||
ForgeDirection dir = entry.getValue();
|
ForgeDirection dir = entry.getValue();
|
||||||
MechanicalNode adjacentMech = entry.getKey();
|
MechanicalNode adjacentMech = entry.getKey();
|
||||||
debug("\tConnection: " + adjacentMech + " Side: " + dir);
|
|
||||||
/** Calculate angular velocity and torque. */
|
/** Calculate angular velocity and torque. */
|
||||||
float ratio = adjacentMech.getRatio(dir.getOpposite(), this) / getRatio(dir, adjacentMech);
|
float ratio = adjacentMech.getRatio(dir.getOpposite(), this) / getRatio(dir, adjacentMech);
|
||||||
boolean inverseRotation = inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), this);
|
boolean inverseRotation = inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), this);
|
||||||
|
@ -295,14 +274,11 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
/** Checks to see if a connection is allowed from side and from a source */
|
/** Checks to see if a connection is allowed from side and from a source */
|
||||||
public boolean canConnect(ForgeDirection from, Object source)
|
public boolean canConnect(ForgeDirection from, Object source)
|
||||||
{
|
{
|
||||||
debug("Node -> Canconnect", CONNECTION_DEBUG);
|
|
||||||
if (source instanceof MechanicalNode)
|
if (source instanceof MechanicalNode)
|
||||||
{
|
{
|
||||||
boolean flag = (connectionMap & (1 << from.ordinal())) != 0;
|
boolean flag = (connectionMap & (1 << from.ordinal())) != 0;
|
||||||
debug("\t" + flag, CONNECTION_DEBUG);
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
debug("\tFalse", CONNECTION_DEBUG);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,15 +311,12 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
@Override
|
@Override
|
||||||
public void reconstruct()
|
public void reconstruct()
|
||||||
{
|
{
|
||||||
debug("reconstruct", CONNECTION_DEBUG);
|
|
||||||
debug("reconstruct");
|
|
||||||
recache();
|
recache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deconstruct()
|
public void deconstruct()
|
||||||
{
|
{
|
||||||
debug("deconstruct");
|
|
||||||
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
|
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
|
||||||
{
|
{
|
||||||
entry.getKey().recache();
|
entry.getKey().recache();
|
||||||
|
@ -354,26 +327,21 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
@Override
|
@Override
|
||||||
public void recache()
|
public void recache()
|
||||||
{
|
{
|
||||||
debug("Node->Recahce", CONNECTION_DEBUG);
|
|
||||||
getConnections().clear();
|
getConnections().clear();
|
||||||
|
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||||
{
|
{
|
||||||
debug("\tDir: " + dir, CONNECTION_DEBUG);
|
|
||||||
TileEntity tile = position().translate(dir).getTileEntity(world());
|
TileEntity tile = position().translate(dir).getTileEntity(world());
|
||||||
debug("\tTile: " + tile, CONNECTION_DEBUG);
|
|
||||||
if (tile instanceof INodeProvider)
|
if (tile instanceof INodeProvider)
|
||||||
{
|
{
|
||||||
debug("\tTile instanceof INodeProvider", CONNECTION_DEBUG);
|
|
||||||
INode node = ((INodeProvider) tile).getNode(MechanicalNode.class, dir.getOpposite());
|
INode node = ((INodeProvider) tile).getNode(MechanicalNode.class, dir.getOpposite());
|
||||||
if (node instanceof MechanicalNode)
|
if (node instanceof MechanicalNode)
|
||||||
{
|
{
|
||||||
debug("\tNode instanceof MechanicalNode", CONNECTION_DEBUG);
|
|
||||||
MechanicalNode check = (MechanicalNode) node;
|
MechanicalNode check = (MechanicalNode) node;
|
||||||
|
boolean canConnect = canConnect(dir, check);
|
||||||
if (check != null && canConnect(dir, check) && check.canConnect(dir.getOpposite(), this))
|
boolean canOtherConnect = check.canConnect(dir.getOpposite(), this);
|
||||||
|
if (canConnect && canOtherConnect)
|
||||||
{
|
{
|
||||||
debug("\tCanConnect and added to connections", CONNECTION_DEBUG);
|
|
||||||
getConnections().put(check, dir);
|
getConnections().put(check, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class GearNode extends MechanicalNode
|
||||||
@Override
|
@Override
|
||||||
public void recache()
|
public void recache()
|
||||||
{
|
{
|
||||||
debug("doRecache: " + this);
|
|
||||||
getConnections().clear();
|
getConnections().clear();
|
||||||
|
|
||||||
/** Only call refresh if this is the main block of a multiblock gear or a single gear block. */
|
/** Only call refresh if this is the main block of a multiblock gear or a single gear block. */
|
||||||
|
@ -162,25 +161,20 @@ public class GearNode extends MechanicalNode
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection from, Object with)
|
public boolean canConnect(ForgeDirection from, Object with)
|
||||||
{
|
{
|
||||||
debug("Node -> CanConnect");
|
|
||||||
if (!gear().getMultiBlock().isPrimary())
|
if (!gear().getMultiBlock().isPrimary())
|
||||||
{
|
{
|
||||||
debug("\tFailed: Gear is multiblock and not primary");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (with instanceof MechanicalNode)
|
if (with instanceof MechanicalNode)
|
||||||
{
|
{
|
||||||
debug("\tWith is a mechnical node");
|
|
||||||
INodeProvider parent = ((MechanicalNode) with).getParent();
|
INodeProvider parent = ((MechanicalNode) with).getParent();
|
||||||
|
|
||||||
/** Check for flat connections (gear face on gear face) */
|
/** Check for flat connections (gear face on gear face) */
|
||||||
if (from == gear().placementSide.getOpposite())
|
if (from == gear().placementSide.getOpposite())
|
||||||
{
|
{
|
||||||
debug("\tChecking back connection");
|
|
||||||
if (parent instanceof PartGear)
|
if (parent instanceof PartGear)
|
||||||
{
|
{
|
||||||
debug("\tconnection is a gear");
|
|
||||||
if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed())
|
if (((PartGear) parent).tile() == gear().tile() && !gear().getMultiBlock().isConstructed())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
|
||||||
public PartGear()
|
public PartGear()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
node = new MechanicalNode(this);
|
node = new GearNode(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
|
||||||
if (manualCrankTime > 0)
|
if (manualCrankTime > 0)
|
||||||
{
|
{
|
||||||
node.apply(this, isClockwiseCrank ? 15 : -15, isClockwiseCrank ? 0.025f : -0.025f);
|
node.apply(this, isClockwiseCrank ? 15 : -15, isClockwiseCrank ? 0.025f : -0.025f);
|
||||||
//manualCrankTime--;
|
manualCrankTime--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMultiBlock().update();
|
getMultiBlock().update();
|
||||||
|
|
Loading…
Reference in a new issue