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)
|
if (manualCrankTime > 0)
|
||||||
{
|
{
|
||||||
getNetwork().onReceiveEnergy(this, 20, 0.2f);
|
getNetwork().onReceiveEnergy(this, 20, 0.4f);
|
||||||
manualCrankTime--;
|
manualCrankTime--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class PartGear extends PartMechanical implements IMechanical
|
||||||
else
|
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.
|
* @return The current rotation value of the network.
|
||||||
*/
|
*/
|
||||||
public float getRotation();
|
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> prevGenerators = new LinkedHashSet<IMechanical>();
|
||||||
private Set<IMechanical> generators = new LinkedHashSet<IMechanical>();
|
private Set<IMechanical> generators = new LinkedHashSet<IMechanical>();
|
||||||
|
private boolean disabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConnector(IMechanical connector)
|
public void addConnector(IMechanical connector)
|
||||||
|
@ -117,7 +118,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
@Override
|
@Override
|
||||||
public boolean canUpdate()
|
public boolean canUpdate()
|
||||||
{
|
{
|
||||||
return true;
|
return !disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,10 +133,11 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
public void sendNetworkPacket()
|
public void sendNetworkPacket()
|
||||||
{
|
{
|
||||||
for (IMechanical connector : this.getConnectors())
|
for (IMechanical connector : this.getConnectors())
|
||||||
{
|
|
||||||
if (connector instanceof TileEntity)
|
|
||||||
{
|
{
|
||||||
int[] location = connector.getLocation();
|
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));
|
PacketDispatcher.sendPacketToAllPlayers(Mechanical.PACKET_NETWORK.getPacket(location[0], location[1], location[2], location[3], (byte) 0, torque, angularVelocity));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +147,8 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
public void sendRotationUpdatePacket(IMechanical connector)
|
public void sendRotationUpdatePacket(IMechanical connector)
|
||||||
{
|
{
|
||||||
int[] location = connector.getLocation();
|
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()));
|
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());
|
updateNode.setClockwise(data.readBoolean());
|
||||||
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(updateNode, this, null);
|
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(updateNode, this, null);
|
||||||
rotationPathfinder.findNodes(updateNode);
|
rotationPathfinder.findNodes(updateNode);
|
||||||
System.out.println("UPDATE");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,6 +232,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
@Override
|
@Override
|
||||||
public void reconstruct()
|
public void reconstruct()
|
||||||
{
|
{
|
||||||
|
disabled = false;
|
||||||
// Reset
|
// Reset
|
||||||
prevTorque = torque = 0;
|
prevTorque = torque = 0;
|
||||||
prevAngularVelocity = angularVelocity = 0;
|
prevAngularVelocity = angularVelocity = 0;
|
||||||
|
@ -277,6 +281,13 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDisabled()
|
||||||
|
{
|
||||||
|
System.out.println("NETWORK DISABLED");
|
||||||
|
disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMechanicalNetwork newInstance()
|
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() + "]";
|
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];
|
protected Object[] connections = new Object[6];
|
||||||
|
|
||||||
/** Side of the block this is placed on */
|
/** Side of the block this is placed on */
|
||||||
public ForgeDirection placementSide;
|
public ForgeDirection placementSide = ForgeDirection.UNKNOWN;
|
||||||
|
|
||||||
/** The size of the gear */
|
/** The size of the gear */
|
||||||
private float radius = 0.5f;
|
private float radius = 0.5f;
|
||||||
|
@ -318,6 +318,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
||||||
@Override
|
@Override
|
||||||
public int[] getLocation()
|
public int[] getLocation()
|
||||||
{
|
{
|
||||||
|
if (tile() != null)
|
||||||
return new int[] { x(), y(), z(), placementSide.ordinal() };
|
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))
|
if ((prevClosedSet != null && prevClosedSet.contains(node)) && (node.isClockwise() != currentRotationFlag))
|
||||||
{
|
{
|
||||||
// We have conflicting rotations. Network is now stuck.
|
// We have conflicting rotations. Network is now stuck.
|
||||||
network.setPower(0, 0);
|
network.setDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
findNodes(node);
|
findNodes(node);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
||||||
@Override
|
@Override
|
||||||
public boolean isRotationInversed()
|
public boolean isRotationInversed()
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue