Made my own path finder checker

It worked without this but just too be safe i copied and changed the one
i was using from UE.
This commit is contained in:
Rseifert 2013-03-30 00:21:33 -04:00
parent 72932508d4
commit 7488a448f0

View file

@ -0,0 +1,48 @@
package hydraulic.core.path;
import hydraulic.api.IPipeConnection;
import java.util.Arrays;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.path.Pathfinder;
/**
* Check if a conductor connects with another.
*/
public class PathfinderCheckerPipes extends Pathfinder
{
public PathfinderCheckerPipes(final IConnectionProvider targetConnector, final IConnectionProvider... ignoreConnector)
{
super(new IPathCallBack()
{
@Override
public boolean isValidNode(Pathfinder finder, ForgeDirection direction, IConnectionProvider provider, IConnectionProvider connectedBlock)
{
if (connectedBlock instanceof IPipeConnection && !Arrays.asList(ignoreConnector).contains(connectedBlock))
{
if (((IPipeConnection) connectedBlock).canConnect((TileEntity) connectedBlock, direction.getOpposite()))
{
return true;
}
}
return false;
}
@Override
public boolean onSearch(Pathfinder finder, IConnectionProvider provider)
{
if (provider == targetConnector)
{
finder.results.add(provider);
return true;
}
return false;
}
});
}
}