Clean up some TransporterPathfinder stuff.
This commit is contained in:
parent
7b4404a973
commit
420e1619e6
2 changed files with 13 additions and 15 deletions
|
@ -1,6 +1,5 @@
|
|||
package mekanism.common.content.transporter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -19,20 +18,19 @@ public class PathfinderCache
|
|||
reset();
|
||||
}
|
||||
|
||||
public static ArrayList<Coord4D> getCache(Coord4D start, Coord4D end, EnumSet<ForgeDirection> sides)
|
||||
public static List<Coord4D> getCache(Coord4D start, Coord4D end, EnumSet<ForgeDirection> sides)
|
||||
{
|
||||
ArrayList<Coord4D> ret = null;
|
||||
List<Coord4D> ret = null;
|
||||
|
||||
for(Map.Entry<PathData, List<Coord4D>> entry : cachedPaths.entrySet())
|
||||
for(ForgeDirection side : sides)
|
||||
{
|
||||
PathData data = entry.getKey();
|
||||
PathData data = new PathData(start, end, side);
|
||||
|
||||
List<Coord4D> test = cachedPaths.get(data);
|
||||
|
||||
if(data.startTransporter.equals(start) && data.end.equals(end) && sides.contains(data.endSide))
|
||||
if(ret == null || (test != null && test.size() < ret.size()))
|
||||
{
|
||||
if(ret == null || entry.getValue().size() < ret.size())
|
||||
{
|
||||
ret = (ArrayList)entry.getValue();
|
||||
}
|
||||
ret = test;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,14 +151,14 @@ public final class TransporterPathfinder
|
|||
|
||||
public static class Destination implements Comparable<Destination>
|
||||
{
|
||||
public List<Coord4D> path = new ArrayList<Coord4D>();
|
||||
public List<Coord4D> path;
|
||||
public Path pathType;
|
||||
public ItemStack rejected;
|
||||
public double score;
|
||||
|
||||
public Destination(ArrayList<Coord4D> list, boolean inv, ItemStack rejects, double gScore)
|
||||
public Destination(List<Coord4D> list, boolean inv, ItemStack rejects, double gScore)
|
||||
{
|
||||
path = (List<Coord4D>)list.clone();
|
||||
path = new ArrayList<>(list);
|
||||
|
||||
if(inv)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ public final class TransporterPathfinder
|
|||
|
||||
public static Destination getPath(DestChecker checker, EnumSet<ForgeDirection> sides, ILogisticalTransporter start, Coord4D dest, TransporterStack stack, ItemStack rejects, int min)
|
||||
{
|
||||
ArrayList<Coord4D> test = PathfinderCache.getCache(start.coord(), dest, sides);
|
||||
List<Coord4D> test = PathfinderCache.getCache(start.coord(), dest, sides);
|
||||
|
||||
if(test != null)
|
||||
{
|
||||
|
@ -489,7 +489,7 @@ public final class TransporterPathfinder
|
|||
{
|
||||
ArrayList<Coord4D> path = new ArrayList<Coord4D>();
|
||||
path.add(finalNode);
|
||||
path.addAll((ArrayList<Coord4D>)results.clone());
|
||||
path.addAll(results);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue