Made mechanical network not pathfind unless the amount of generators changed
This commit is contained in:
parent
18ae602065
commit
a7f19b20a2
2 changed files with 15 additions and 13 deletions
|
@ -47,7 +47,7 @@ public class PartGear extends PartMechanical implements IMechanical
|
||||||
@Override
|
@Override
|
||||||
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
|
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))
|
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), tile().xCoord, tile().yCoord, tile().zCoord))
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,22 +74,24 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
/**
|
/**
|
||||||
* Calculation rotations of all generators.
|
* 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)
|
||||||
|
|
||||||
for (IMechanical generatorNode : generators)
|
|
||||||
{
|
|
||||||
if (generatorNode != null)
|
|
||||||
{
|
{
|
||||||
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(generatorNode, this, closedSet);
|
if (generatorNode != null)
|
||||||
rotationPathfinder.findNodes(generatorNode);
|
{
|
||||||
closedSet.addAll(rotationPathfinder.closedSet);
|
PathfinderUpdateRotation rotationPathfinder = new PathfinderUpdateRotation(generatorNode, this, closedSet);
|
||||||
sendRotationUpdatePacket(generatorNode);
|
rotationPathfinder.findNodes(generatorNode);
|
||||||
|
closedSet.addAll(rotationPathfinder.closedSet);
|
||||||
|
sendRotationUpdatePacket(generatorNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
generators.clear();
|
prevGenerators = new LinkedHashSet<>(generators);
|
||||||
|
generators.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate load
|
* Calculate load
|
||||||
|
|
Loading…
Reference in a new issue