Made mechanical network not pathfind unless the amount of generators changed

This commit is contained in:
Calclavia 2014-01-21 19:15:20 +08:00
parent 18ae602065
commit a7f19b20a2
2 changed files with 15 additions and 13 deletions

View file

@ -47,7 +47,7 @@ public class PartGear extends PartMechanical implements IMechanical
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
{
System.out.println(world().isRemote + ": " + getNetwork());
//System.out.println(world().isRemote + ": " + getNetwork());
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), tile().xCoord, tile().yCoord, tile().zCoord))
{

View file

@ -74,22 +74,24 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
/**
* Calculation rotations of all generators.
*/
prevGenerators = generators;
if (!(prevGenerators.equals(generators)) && generators.size() > 0)
{System.out.println("UPDA PATH");
Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>();
Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>();
for (IMechanical generatorNode : generators)
{
if (generatorNode != null)
for (IMechanical generatorNode : generators)
{
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(generatorNode, this, closedSet);
rotationPathfinder.findNodes(generatorNode);
closedSet.addAll(rotationPathfinder.closedSet);
sendRotationUpdatePacket(generatorNode);
if (generatorNode != null)
{
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(generatorNode, this, closedSet);
rotationPathfinder.findNodes(generatorNode);
closedSet.addAll(rotationPathfinder.closedSet);
sendRotationUpdatePacket(generatorNode);
}
}
}
generators.clear();
prevGenerators = new LinkedHashSet<>(generators);
generators.clear();
}
/**
* Calculate load