Created a new networkPipe base on UE's Conductor

My network code is about the same as UE's short of the fact i have to
still ably to net.minecraftForge.Liquids interfaces in order to keep my
mod compatibly with other mods. So its only logical that my network pipe
updates, reacts, and works the same as the UE conductor.  Though i will
be making change to mine in order to have it function with liquids more
and more.
This commit is contained in:
Rseifert 2013-03-26 15:09:20 -04:00
parent 0a020c24df
commit b685fda4c3
7 changed files with 481 additions and 390 deletions

View file

@ -0,0 +1,317 @@
package fluidmech.common.machines.pipes;
import fluidmech.common.FluidMech;
import hydraulic.api.ColorCode;
import hydraulic.api.IColorCoded;
import hydraulic.api.ILiquidNetworkPart;
import hydraulic.api.IPipeConnector;
import hydraulic.api.IReadOut;
import hydraulic.core.liquidNetwork.HydraulicNetwork;
import hydraulic.helpers.connectionHelper;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import org.bouncycastle.util.Arrays;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityNetworkPipe extends TileEntityAdvanced implements ITankContainer, IReadOut, IColorCoded, ILiquidNetworkPart, IPacketReceiver
{
/* COLOR CODE THIS PIPE USES FOR CONNECTION RULES */
private ColorCode color = ColorCode.NONE;
/* TANK TO FAKE OTHER TILES INTO BELIVING THIS HAS AN INTERNAL STORAGE */
private LiquidTank fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
/* CURRENTLY CONNECTED TILE ENTITIES TO THIS */
public TileEntity[] connectedBlocks = new TileEntity[6];
public boolean[] renderConnection = new boolean[6];
/* RANDOM INSTANCE USED BY THE UPDATE TICK */
private Random random = new Random();
/* NETWORK INSTANCE THAT THIS PIPE USES */
private HydraulicNetwork pipeNetwork;
@Override
public void updateEntity()
{
if (worldObj.isRemote && ticks % ((int) random.nextInt() * 100) == 0)
{
this.updateAdjacentConnections();
}
}
@Override
public void initiate()
{
this.color = ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
this.updateAdjacentConnections();
}
@Override
public void invalidate()
{
if (!this.worldObj.isRemote)
{
this.getNetwork().splitNetwork(this);
}
super.invalidate();
}
@Override
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (this.worldObj.isRemote)
{
this.renderConnection[0] = dataStream.readBoolean();
this.renderConnection[1] = dataStream.readBoolean();
this.renderConnection[2] = dataStream.readBoolean();
this.renderConnection[3] = dataStream.readBoolean();
this.renderConnection[4] = dataStream.readBoolean();
this.renderConnection[5] = dataStream.readBoolean();
}
}
@Override
public Packet getDescriptionPacket()
{
return PacketManager.getPacket(FluidMech.CHANNEL, this, this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]);
}
/**
* gets the current color mark of the pipe
*/
@Override
public ColorCode getColor()
{
return this.color;
}
/**
* sets the current color mark of the pipe
*/
@Override
public void setColor(Object cc)
{
this.color = ColorCode.get(cc);
}
/**
* sets the current color mark of the pipe
*/
public void setColor(int i)
{
if (i < ColorCode.values().length)
{
this.color = ColorCode.values()[i];
}
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side)
{
return this.getNetwork().pressureProduced + "p";
}
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
if (resource == null || !this.color.isValidLiquid(resource))
{
return 0;
}
return this.fill(0, resource, doFill);
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
if (tankIndex != 0 || resource == null || !this.color.isValidLiquid(resource))
{
return 0;
}
return this.getNetwork().addFluidToNetwork(resource, 0, doFill);
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
{
return new ILiquidTank[] { this.fakeTank };
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
{
if (this.color.isValidLiquid(type))
{
return this.fakeTank;
}
return null;
}
/**
* collects and sorts the surrounding TE for valid connections
*/
public void validataConnectionSide(TileEntity tileEntity, ForgeDirection side)
{
if (!this.worldObj.isRemote)
{
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof ILiquidNetworkPart)
{
this.getNetwork().mergeNetworks(((ILiquidNetworkPart) tileEntity).getNetwork());
}
if (tileEntity instanceof IColorCoded && this.color != ((IColorCoded) tileEntity).getColor())
{
connectedBlocks[side.ordinal()] = null;
}
if (tileEntity instanceof ITankContainer)
{
// TODO
}
else if (tileEntity instanceof IPipeConnector && !((IPipeConnector) tileEntity).canConnect(side, color.getLiquidData().getStack()))
{
connectedBlocks[side.ordinal()] = null;
}
else
{
connectedBlocks[side.ordinal()] = null;
}
}
}
@Override
public boolean canConnect(ForgeDirection dir, LiquidStack... stacks)
{
for (int i = 0; i < stacks.length; i++)
{
if (this.color.isValidLiquid(stacks[i]))
{
return true;
}
}
return false;
}
@Override
public double getMaxPressure(ForgeDirection side)
{
return 350;
}
@Override
public HydraulicNetwork getNetwork()
{
return this.pipeNetwork;
}
@Override
public void setNetwork(HydraulicNetwork network)
{
if (this.pipeNetwork == null)
{
this.setNetwork(new HydraulicNetwork(color));
}
this.pipeNetwork = network;
}
@Override
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
{
return LiquidContainerRegistry.BUCKET_VOLUME * 2;
}
@Override
public boolean onOverPressure(Boolean damageAllowed)
{
if (damageAllowed)
{
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0, 3);
return true;
}
return false;
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
}
@Override
public TileEntity[] getAdjacentConnections()
{
return this.connectedBlocks;
}
@Override
public void updateAdjacentConnections()
{
if (this.worldObj != null)
{
if (!this.worldObj.isRemote)
{
boolean[] previousConnections = this.renderConnection.clone();
this.connectedBlocks = connectionHelper.getSurroundingTileEntities(this);
for (byte i = 0; i < 6; i++)
{
this.validataConnectionSide(VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
}
for (int i = 0; i < 6; i++)
{
this.renderConnection[i] = this.connectedBlocks[i] != null;
}
/**
* Only send packet updates if visuallyConnected changed.
*/
if (!Arrays.areEqual(previousConnections, this.renderConnection))
{
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
}
}
}
@Override
public boolean canConnect(ForgeDirection direction)
{
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,5 +1,6 @@
package hydraulic.api;
import universalelectricity.core.block.IConnectionProvider;
import hydraulic.core.liquidNetwork.HydraulicNetwork;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@ -10,13 +11,18 @@ import net.minecraftforge.liquids.LiquidStack;
* that doesn't change the over all network pressure. So pipes, gauges, tubes, buffers, decor
* blocks.
*/
public interface ILiquidNetworkPart extends IPipeConnector
public interface ILiquidNetworkPart extends IPipeConnector, IColorCoded, IConnectionProvider
{
/**
* gets the devices pressure from a given side for input
*/
public double getMaxPressure(ForgeDirection side);
/**
* The max amount of liquid that can flow per request
*/
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side);
/**
* The Fluid network that this machine is part of
*/
@ -27,18 +33,6 @@ public interface ILiquidNetworkPart extends IPipeConnector
*/
public void setNetwork(HydraulicNetwork network);
/**
* The tileEntities surrounding the block
*
* @return
*/
public TileEntity[] getConnectedBlocks();
/**
* The max amount of liquid that can flow per request
*/
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side);
/**
* Called when the pressure on the machine reachs max
*
@ -47,24 +41,4 @@ public interface ILiquidNetworkPart extends IPipeConnector
*/
public boolean onOverPressure(Boolean damageAllowed);
/**
* Resets the pipe and recalculate connection IDs again
*/
public void reset();
/**
* Instantly refreshes all connected blocks
*/
public void refreshConnectedBlocks();
/**
* Adds a connection between this machine and another machine
*
* @param tileEntity - Must be either a producer, consumer or a conductor
* @param side - side in which the connection is coming from
*/
public void updateConnection(TileEntity tileEntity, ForgeDirection side);
public void updateConnectionWithoutSplit(TileEntity connectorFromSide, ForgeDirection orientation);
}

View file

@ -1,41 +1,22 @@
package hydraulic.core;
import hydraulic.core.liquidNetwork.HydraulicNetworkManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.FMLLog;
public class HydraulicLoader
{
public static final HydraulicLoader INSTANCE = new HydraulicLoader();
public static final HydraulicLoader INSTANCE = new HydraulicLoader();
public static boolean isInitialized = false;
public static boolean isInitialized = false;
public void initiate()
{
if (!isInitialized)
{
HydraulicNetworkManager.instance = new HydraulicNetworkManager();
MinecraftForge.EVENT_BUS.register(this);
public void initiate()
{
if (!isInitialized)
{
// MinecraftForge.EVENT_BUS.register(this);
FMLLog.finest("Hydraulics v" + Hydraulics.VERSION + " loaded without error!");
FMLLog.finest("Hydraulics v" + Hydraulics.VERSION + " loaded without error!");
isInitialized = true;
}
}
@ForgeSubscribe
public void onWorldUnLoad(WorldEvent.Unload event)
{
HydraulicNetworkManager.instance = new HydraulicNetworkManager();
HydraulicNetworkManager.instance.cleanUpNetworks();
}
@ForgeSubscribe
public void onWorldLoad(WorldEvent.Load event)
{
HydraulicNetworkManager.instance = new HydraulicNetworkManager();
HydraulicNetworkManager.instance.cleanUpNetworks();
}
isInitialized = true;
}
}
}

View file

@ -1,22 +1,25 @@
package hydraulic.core.liquidNetwork;
import hydraulic.api.ColorCode;
import hydraulic.api.ILiquidNetworkPart;
import hydraulic.api.IPipeConnector;
import hydraulic.api.IPsiCreator;
import hydraulic.api.ILiquidNetworkPart;
import hydraulic.api.IPsiReciever;
import hydraulic.helpers.connectionHelper;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import universalelectricity.prefab.network.IPacketReceiver;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidStack;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.path.Pathfinder;
import universalelectricity.core.path.PathfinderChecker;
import cpw.mods.fml.common.FMLLog;
/**
* Side note: the network should act like this when done {@link http
@ -40,9 +43,8 @@ public class HydraulicNetwork
/* PRESSURE OF THE NETWORK'S LOAD AS A TOTAL. ZERO AS IN NO LOAD */
public double pressureLoad = 0;
public HydraulicNetwork(ILiquidNetworkPart conductor, ColorCode color)
public HydraulicNetwork(ColorCode color)
{
this.addConductor(conductor, color);
this.color = color;
}
@ -79,7 +81,7 @@ public class HydraulicNetwork
*
* @return The amount of Liquid used.
*/
public int addFluidToNetwork(LiquidStack stack, double pressure)
public int addFluidToNetwork(LiquidStack stack, double pressure, boolean doFill)
{
int used = 0;
if (stack != null && canAcceptLiquid(stack))
@ -152,13 +154,16 @@ public class HydraulicNetwork
return used;
}
}// End of tank finder
if (fillTarget != null)
if (doFill)
{
used = fillTarget.fill(fillDir, stack, true);
}
else if (otherFillTarget != null)
{
used = otherFillTarget.fill(fillDir, stack, true);
if (fillTarget != null)
{
used = fillTarget.fill(fillDir, stack, true);
}
else if (otherFillTarget != null)
{
used = otherFillTarget.fill(fillDir, stack, true);
}
}
}
@ -243,14 +248,6 @@ public class HydraulicNetwork
}
}
public void resetConductors()
{
for (int i = 0; i < conductors.size(); i++)
{
conductors.get(i).reset();
}
}
public void setNetwork()
{
this.cleanConductors();
@ -278,14 +275,141 @@ public class HydraulicNetwork
}
}
public void cleanUpConductors()
{
Iterator it = this.conductors.iterator();
while (it.hasNext())
{
ILiquidNetworkPart conductor = (ILiquidNetworkPart) it.next();
if (conductor == null)
{
it.remove();
}
else if (((TileEntity) conductor).isInvalid())
{
it.remove();
}
else
{
conductor.setNetwork(this);
}
}
}
/**
* This function is called to refresh all conductors in this network
*/
public void refreshConductors()
{
for (int j = 0; j < this.conductors.size(); j++)
this.cleanUpConductors();
try
{
this.conductors.get(j).refreshConnectedBlocks();
Iterator<ILiquidNetworkPart> it = this.conductors.iterator();
while (it.hasNext())
{
ILiquidNetworkPart conductor = it.next();
conductor.updateAdjacentConnections();
}
}
catch (Exception e)
{
FMLLog.severe("Universal Electricity: Failed to refresh conductor.");
e.printStackTrace();
}
}
public List<ILiquidNetworkPart> getFluidNetworkParts()
{
return this.conductors;
}
public void mergeNetworks(HydraulicNetwork network)
{
if (network != null && network != this && network.color == this.color)
{
HydraulicNetwork newNetwork = new HydraulicNetwork(this.color);
newNetwork.getFluidNetworkParts().addAll(this.getFluidNetworkParts());
newNetwork.getFluidNetworkParts().addAll(network.getFluidNetworkParts());
newNetwork.cleanUpConductors();
}
}
public void splitNetwork(IConnectionProvider splitPoint)
{
if (splitPoint instanceof TileEntity)
{
this.getFluidNetworkParts().remove(splitPoint);
/**
* Loop through the connected blocks and attempt to see if there are connections between
* the two points elsewhere.
*/
TileEntity[] connectedBlocks = splitPoint.getAdjacentConnections();
for (int i = 0; i < connectedBlocks.length; i++)
{
TileEntity connectedBlockA = connectedBlocks[i];
if (connectedBlockA instanceof IConnectionProvider)
{
for (int ii = 0; ii < connectedBlocks.length; ii++)
{
final TileEntity connectedBlockB = connectedBlocks[ii];
if (connectedBlockA != connectedBlockB && connectedBlockB instanceof IConnectionProvider)
{
Pathfinder finder = new PathfinderChecker((IConnectionProvider) connectedBlockB, splitPoint);
finder.init((IConnectionProvider) connectedBlockA);
if (finder.results.size() > 0)
{
/**
* The connections A and B are still intact elsewhere. Set all
* references of wire connection into one network.
*/
for (IConnectionProvider node : finder.iteratedNodes)
{
if (node instanceof ILiquidNetworkPart)
{
if (node != splitPoint)
{
((ILiquidNetworkPart) node).setNetwork(this);
}
}
}
}
else
{
/**
* The connections A and B are not connected anymore. Give both of
* them a new network.
*/
HydraulicNetwork newNetwork = new HydraulicNetwork(this.color);
for (IConnectionProvider node : finder.iteratedNodes)
{
if (node instanceof ILiquidNetworkPart)
{
if (node != splitPoint)
{
newNetwork.getFluidNetworkParts().add((ILiquidNetworkPart) node);
}
}
}
newNetwork.cleanUpConductors();
}
}
}
}
}
}
}

View file

@ -1,154 +0,0 @@
package hydraulic.core.liquidNetwork;
import hydraulic.api.ColorCode;
import hydraulic.api.ILiquidNetworkPart;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import cpw.mods.fml.common.FMLLog;
/**
* based on Calclavia's UE Electric Network stuff
*
*/
public class HydraulicNetworkManager
{
public static HydraulicNetworkManager instance = new HydraulicNetworkManager();
private List<HydraulicNetwork> hydraulicNetworks = new ArrayList<HydraulicNetwork>();
/**
* Registers a pipe into the network, if not using a specific color give ColorCode.NONE
*/
public void registerConductor(ILiquidNetworkPart newConductor, ColorCode color)
{
this.cleanUpNetworks();
HydraulicNetwork newNetwork = new HydraulicNetwork(newConductor, color);
this.hydraulicNetworks.add(newNetwork);
}
/**
* unregisters a tileEntity from the network
*
* @param tileEntity
*/
public void unregister(TileEntity tileEntity)
{
for (HydraulicNetwork network : this.hydraulicNetworks)
{
network.removeEntity(tileEntity);
}
}
/**
* Merges two connection lines together into one.
*
* @param networkA - The network to be merged into. This network will be kept.
* @param networkB - The network to be merged. This network will be deleted.
*/
public void mergeConnection(HydraulicNetwork networkA, HydraulicNetwork networkB)
{
if (networkA != networkB)
{
if (networkA != null && networkB != null)
{
networkA.conductors.addAll(networkB.conductors);
networkA.setNetwork();
this.hydraulicNetworks.remove(networkB);
networkB = null;
networkA.cleanConductors();
}
else
{
System.err.println("Failed to merge pipe connections!");
}
}
}
/**
* Separate one connection line into two different ones between two conductors. This function
* does this by resetting all wires in the connection line and making them each reconnect.
*
* @param conductorA - existing conductor
* @param conductorB - broken/invalid conductor
*/
public void splitConnection(ILiquidNetworkPart conductorA, ILiquidNetworkPart conductorB)
{
try
{
HydraulicNetwork network = conductorA.getNetwork();
if (network != null)
{
network.cleanConductors();
network.resetConductors();
Iterator it = network.conductors.iterator();
while (it.hasNext())
{
ILiquidNetworkPart conductor = (ILiquidNetworkPart) it.next();
for (byte i = 0; i < 6; i++)
{
conductor.updateConnectionWithoutSplit(VectorHelper.getConnectorFromSide(((TileEntity) conductor).worldObj, new Vector3((TileEntity) conductor), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
}
}
}
else
{
FMLLog.severe("Conductor invalid network while splitting connection!");
}
}
catch (Exception e)
{
FMLLog.severe("Failed to split wire connection!");
e.printStackTrace();
}
}
/**
* Clean up and remove all useless and invalid connections.
*/
public void cleanUpNetworks()
{
try
{
Iterator it = hydraulicNetworks.iterator();
while (it.hasNext())
{
HydraulicNetwork network = (HydraulicNetwork) it.next();
network.cleanConductors();
if (network.conductors.size() == 0)
{
it.remove();
}
}
}
catch (Exception e)
{
FMLLog.severe("Failed to clean up wire connections!");
e.printStackTrace();
}
}
public void resetConductors()
{
Iterator it = hydraulicNetworks.iterator();
while (it.hasNext())
{
HydraulicNetwork network = ((HydraulicNetwork) it.next());
network.resetConductors();
}
}
}

View file

@ -1,119 +0,0 @@
package hydraulic.core.path;
import hydraulic.helpers.connectionHelper;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
/**
* A class that allows flexible path finding in Minecraft Blocks.
*
* @author Calclavia, DarkGuardsman
*
*/
public class Pathfinder
{
public Vector3 target;
/**
* A list of nodes that the pathfinder went through.
*/
public List<Vector3> searchedNodes;
/**
* A list of valid block IDs to use as a path.
*/
public List<Integer> blockIDs;
/**
* The results and findings found by the pathfinder.
*/
public List results;
public World world;
public Pathfinder(World world, List<Integer> blockIDs)
{
this.blockIDs = blockIDs;
this.world = world;
this.clear();
}
public boolean findNodes(Vector3 location)
{
int[] connectedBlocks = connectionHelper.getSurroundingBlocks(world, location);
this.searchedNodes.add(location);
if (this.onSearch(location))
{
return false;
}
for (int i = 0; i < connectedBlocks.length; i++)
{
if (blockIDs.contains(connectedBlocks[i]))
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
Vector3 dirLoc = new Vector3(location.intX() + dir.offsetX, location.intY() + dir.offsetY, location.intZ() + dir.offsetZ);
if (!searchedNodes.contains(dirLoc) && this.isValidNode(dir, dirLoc))
{
if (!this.findNodes(dirLoc))
{
return false;
}
}
}
}
return true;
}
/**
* Is this a valid node to search for?
*
* @return
*/
public boolean isValidNode(ForgeDirection direction, Vector3 foundNode)
{
return true;
}
/**
* Called when looping through nodes.
*
* @param finder
* @param provider
* @return True to stop the path finding operation.
*/
public boolean onSearch(Vector3 location)
{
if (location == target)
{
this.results.add(location);
return true;
}
return false;
}
/**
* Called to execute the pathfinding operation.
*/
public Pathfinder init(Vector3 start, Vector3 target)
{
this.target = target;
this.findNodes(start);
return this;
}
public Pathfinder clear()
{
this.searchedNodes = new ArrayList<Vector3>();
this.results = new ArrayList();
return this;
}
}

View file

@ -1,32 +0,0 @@
package hydraulic.core.path;
import java.util.Arrays;
import java.util.List;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
/**
* Check if a conductor connects with another.
*
* @author Calclavia, DarkGuardsman
*
*/
public class PathfinderChecker extends Pathfinder
{
List<Vector3> ignoreList;
public PathfinderChecker(World world, Vector3 targetConnector, List<Integer> blockIds, Vector3... ignoreConnector)
{
super(world, blockIds);
this.ignoreList = Arrays.asList(ignoreConnector);
this.target = targetConnector;
}
@Override
public boolean isValidNode(ForgeDirection direction, Vector3 connectedBlock)
{
return !ignoreList.contains(connectedBlock);
}
}