Patched some sync blocks preventing mechanical concurrent modification
This commit is contained in:
parent
38aa020db3
commit
0daba1a577
|
@ -17,29 +17,47 @@ import universalelectricity.api.vector.IVectorWorld;
|
|||
import universalelectricity.api.vector.Vector3;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
/** A mechanical node for mechanical energy.
|
||||
/**
|
||||
* A mechanical node for mechanical energy.
|
||||
*
|
||||
* @author Calclavia, Darkguardsman */
|
||||
* @author Calclavia, Darkguardsman
|
||||
*/
|
||||
public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
||||
{
|
||||
/** Is debug enabled for the node */
|
||||
/**
|
||||
* Is debug enabled for the node
|
||||
*/
|
||||
public boolean doDebug = false;
|
||||
/** Used to note that you should trigger a packet update for rotation */
|
||||
/**
|
||||
* Used to note that you should trigger a packet update for rotation
|
||||
*/
|
||||
public boolean markRotationUpdate = false;
|
||||
public boolean markTorqueUpdate = false;
|
||||
/** Which section of debug is enabled */
|
||||
/**
|
||||
* Which section of debug is enabled
|
||||
*/
|
||||
public int debugCue = 0, maxDebugCue = 1, minDebugCue = 0;
|
||||
public static final int UPDATE_DEBUG = 0, CONNECTION_DEBUG = 1;
|
||||
/** Rotational Force */
|
||||
/**
|
||||
* Rotational Force
|
||||
*/
|
||||
public double torque = 0, prevTorque;
|
||||
/** Rotational speed */
|
||||
/**
|
||||
* Rotational speed
|
||||
*/
|
||||
public double prevAngularVelocity, angularVelocity = 0;
|
||||
/** Rotational acceleration */
|
||||
/**
|
||||
* Rotational acceleration
|
||||
*/
|
||||
public float acceleration = 2f;
|
||||
|
||||
/** The current rotation of the mechanical node. */
|
||||
/**
|
||||
* The current rotation of the mechanical node.
|
||||
*/
|
||||
public double renderAngle = 0, prev_angle = 0;
|
||||
/** Limits the max distance an object can rotate in a single update */
|
||||
/**
|
||||
* Limits the max distance an object can rotate in a single update
|
||||
*/
|
||||
protected double maxDeltaAngle = Math.toRadians(180);
|
||||
|
||||
protected double load = 2;
|
||||
|
@ -205,7 +223,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
|
||||
}
|
||||
|
||||
/** Called when one revolution is made. */
|
||||
/**
|
||||
* Called when one revolution is made.
|
||||
*/
|
||||
protected void revolve()
|
||||
{
|
||||
|
||||
|
@ -242,7 +262,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
return true;
|
||||
}
|
||||
|
||||
/** The energy percentage loss due to resistance in seconds. */
|
||||
/**
|
||||
* The energy percentage loss due to resistance in seconds.
|
||||
*/
|
||||
public double getTorqueLoad()
|
||||
{
|
||||
return load;
|
||||
|
@ -253,7 +275,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
return load;
|
||||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
if (source instanceof MechanicalNode)
|
||||
|
@ -309,6 +333,8 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
|
||||
@Override
|
||||
public void recache()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
getConnections().clear();
|
||||
|
||||
|
@ -331,14 +357,19 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the node provider for this node */
|
||||
/**
|
||||
* Gets the node provider for this node
|
||||
*/
|
||||
public INodeProvider getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
/** Sets the node provider for the node */
|
||||
/**
|
||||
* Sets the node provider for the node
|
||||
*/
|
||||
public void setParent(INodeProvider parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
|
@ -369,9 +400,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
@Override
|
||||
public double z()
|
||||
{
|
||||
if(this.getParent() instanceof TileEntity)
|
||||
if (this.getParent() instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity)this.getParent()).zCoord;
|
||||
return ((TileEntity) this.getParent()).zCoord;
|
||||
}
|
||||
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).z() : 0;
|
||||
}
|
||||
|
@ -379,9 +410,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
@Override
|
||||
public double x()
|
||||
{
|
||||
if(this.getParent() instanceof TileEntity)
|
||||
if (this.getParent() instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity)this.getParent()).xCoord;
|
||||
return ((TileEntity) this.getParent()).xCoord;
|
||||
}
|
||||
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).x() : 0;
|
||||
}
|
||||
|
@ -389,9 +420,9 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
|||
@Override
|
||||
public double y()
|
||||
{
|
||||
if(this.getParent() instanceof TileEntity)
|
||||
if (this.getParent() instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity)this.getParent()).yCoord;
|
||||
return ((TileEntity) this.getParent()).yCoord;
|
||||
}
|
||||
return this.getParent() instanceof TMultiPart && ((TMultiPart) this.getParent()).tile() != null ? ((TMultiPart) this.getParent()).y() : 0;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ import codechicken.lib.vec.Rotation;
|
|||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
/** Node for the gear
|
||||
/**
|
||||
* Node for the gear
|
||||
*
|
||||
* @author Calclavia, Edited by: Darkguardsman */
|
||||
* @author Calclavia, Edited by: Darkguardsman
|
||||
*/
|
||||
public class GearNode extends MechanicalNode
|
||||
{
|
||||
public GearNode(PartGear parent)
|
||||
|
@ -80,6 +82,8 @@ public class GearNode extends MechanicalNode
|
|||
|
||||
@Override
|
||||
public void recache()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
getConnections().clear();
|
||||
|
||||
|
@ -152,12 +156,15 @@ public class GearNode extends MechanicalNode
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Can this gear be connected BY the source?
|
||||
/**
|
||||
* Can this gear be connected BY the source?
|
||||
*
|
||||
* @param from - Direction source is coming from.
|
||||
* @param with - The source of the connection.
|
||||
* @return True is so. */
|
||||
* @return True is so.
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object with)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,8 @@ public class GearShaftNode extends MechanicalNode
|
|||
|
||||
@Override
|
||||
public void recache()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
getConnections().clear();
|
||||
List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
|
||||
|
@ -88,6 +90,7 @@ public class GearShaftNode extends MechanicalNode
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
|
|
Loading…
Reference in a new issue