Added gear disabling upon wrong rotation
This commit is contained in:
parent
5bc0d45912
commit
18ae602065
6 changed files with 30 additions and 11 deletions
|
@ -30,7 +30,7 @@ public class PartGear extends PartMechanical implements IMechanical
|
|||
{
|
||||
if (manualCrankTime > 0)
|
||||
{
|
||||
getNetwork().onReceiveEnergy(this, 20, 0.2f);
|
||||
getNetwork().onReceiveEnergy(this, 20, 0.4f);
|
||||
manualCrankTime--;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class PartGear extends PartMechanical implements IMechanical
|
|||
else
|
||||
{
|
||||
|
||||
this.manualCrankTime = 20;
|
||||
this.manualCrankTime = 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,4 +38,9 @@ public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechan
|
|||
* @return The current rotation value of the network.
|
||||
*/
|
||||
public float getRotation();
|
||||
|
||||
/**
|
||||
* Disables the network due to rotation issues.
|
||||
*/
|
||||
public void setDisabled();
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
|
||||
private Set<IMechanical> prevGenerators = new LinkedHashSet<IMechanical>();
|
||||
private Set<IMechanical> generators = new LinkedHashSet<IMechanical>();
|
||||
private boolean disabled;
|
||||
|
||||
@Override
|
||||
public void addConnector(IMechanical connector)
|
||||
|
@ -117,7 +118,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
return !disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -132,10 +133,11 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
public void sendNetworkPacket()
|
||||
{
|
||||
for (IMechanical connector : this.getConnectors())
|
||||
{
|
||||
if (connector instanceof TileEntity)
|
||||
{
|
||||
int[] location = connector.getLocation();
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 0, torque, angularVelocity));
|
||||
break;
|
||||
}
|
||||
|
@ -145,6 +147,8 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
public void sendRotationUpdatePacket(IMechanical connector)
|
||||
{
|
||||
int[] location = connector.getLocation();
|
||||
|
||||
if (location != null)
|
||||
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 1, connector.isClockwise()));
|
||||
}
|
||||
|
||||
|
@ -163,7 +167,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
updateNode.setClockwise(data.readBoolean());
|
||||
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(updateNode, this, null);
|
||||
rotationPathfinder.findNodes(updateNode);
|
||||
System.out.println("UPDATE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +232,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
@Override
|
||||
public void reconstruct()
|
||||
{
|
||||
disabled = false;
|
||||
// Reset
|
||||
prevTorque = torque = 0;
|
||||
prevAngularVelocity = angularVelocity = 0;
|
||||
|
@ -277,6 +281,13 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled()
|
||||
{
|
||||
System.out.println("NETWORK DISABLED");
|
||||
disabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMechanicalNetwork newInstance()
|
||||
{
|
||||
|
@ -294,4 +305,5 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
{
|
||||
return this.getClass().getSimpleName() + "[" + this.hashCode() + ", Handlers: " + getConnectors().size() + ", Connectors: " + getConnectors().size() + ", Power:" + getPower() + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
|||
protected Object[] connections = new Object[6];
|
||||
|
||||
/** Side of the block this is placed on */
|
||||
public ForgeDirection placementSide;
|
||||
public ForgeDirection placementSide = ForgeDirection.UNKNOWN;
|
||||
|
||||
/** The size of the gear */
|
||||
private float radius = 0.5f;
|
||||
|
@ -318,6 +318,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
|||
@Override
|
||||
public int[] getLocation()
|
||||
{
|
||||
if (tile() != null)
|
||||
return new int[] { x(), y(), z(), placementSide.ordinal() };
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ public class PathfinderUpdateRotation extends ConnectionPathfinder<IMechanical>
|
|||
if ((prevClosedSet != null && prevClosedSet.contains(node)) && (node.isClockwise() != currentRotationFlag))
|
||||
{
|
||||
// We have conflicting rotations. Network is now stuck.
|
||||
network.setPower(0, 0);
|
||||
network.setDisabled();
|
||||
}
|
||||
|
||||
findNodes(node);
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
@Override
|
||||
public boolean isRotationInversed()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue