cleanup
This commit is contained in:
parent
13699c24b3
commit
6f9da55b87
2 changed files with 2 additions and 141 deletions
|
@ -121,9 +121,9 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
|
|||
TileEntity entity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), getFacing(false));
|
||||
if (entity instanceof ITankContainer)
|
||||
{
|
||||
//return ((ITankContainer) entity).fill(getFacing(false).getOpposite(), resource, doFill);
|
||||
return ((ITankContainer) entity).fill(getFacing(false).getOpposite(), resource, doFill);
|
||||
}
|
||||
return resource.amount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
package fluidmech.common.pump.path;
|
||||
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* A simpler pathfinder based on Calclavia's PathFinder from UE api
|
||||
*/
|
||||
public class LiquidPathFinder2D
|
||||
{
|
||||
private World world; /* MC WORLD */
|
||||
public List<Vector3> nodes = new ArrayList<Vector3>(); /*
|
||||
* LOCATIONs THE PATH FINDER HAS GONE
|
||||
* OVER
|
||||
*/
|
||||
public List<Vector3> results = new ArrayList<Vector3>();/* LOCATIONS THAT ARE VALID RESULTS */
|
||||
private boolean fill; /* ARE WE FILLING THE PATH OR DRAINING THE PATH */
|
||||
private ForgeDirection priority; /* BASED ON fill -- WHICH DIRECTION WILL THE PATH GO FIRST */
|
||||
private int resultLimit = 2000;
|
||||
|
||||
public LiquidPathFinder2D(final World world, final int resultLimit)
|
||||
{
|
||||
this.world = world;
|
||||
this.fill = fill;
|
||||
if (fill)
|
||||
{
|
||||
priority = ForgeDirection.DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
priority = ForgeDirection.UP;
|
||||
}
|
||||
this.resultLimit = resultLimit;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True on success finding, false on failure.
|
||||
*/
|
||||
public boolean findNodes(final Vector3 node)
|
||||
{
|
||||
try
|
||||
{
|
||||
Vector3 vec = node.clone();
|
||||
this.nodes.add(node);
|
||||
Chunk chunk = this.world.getChunkFromBlockCoords(vec.intX(), vec.intZ());
|
||||
|
||||
if (chunk == null || !chunk.isChunkLoaded)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int id = node.getBlockID(world);
|
||||
int meta = node.getBlockID(world);
|
||||
if (this.fill && (id == 0 || (FluidHelper.getLiquidFromBlockId(id) != null && meta != 0)))
|
||||
{
|
||||
this.results.add(node);
|
||||
}
|
||||
else if (!this.fill && FluidHelper.isSourceBlock(world, node))
|
||||
{
|
||||
this.results.add(node);
|
||||
}
|
||||
|
||||
if (this.isDone(node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (direction != ForgeDirection.DOWN && direction != ForgeDirection.UP)
|
||||
{
|
||||
vec = node.clone().modifyPositionFromSide(direction);
|
||||
if (this.isValidNode(vec) & !this.nodes.contains(vec))
|
||||
{
|
||||
if (this.findNodes(vec))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValidNode(Vector3 pos)
|
||||
{
|
||||
int blockID = pos.getBlockID(world);
|
||||
if (!this.fill)
|
||||
{
|
||||
return FluidHelper.getLiquidFromBlockId(pos.getBlockID(world)) != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FluidHelper.getLiquidFromBlockId(pos.getBlockID(world)) != null || (blockID == 0 && FluidHelper.getConnectedSources(world, pos) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDone(Vector3 vec)
|
||||
{
|
||||
if (this.results.size() >= this.resultLimit || this.nodes.size() >= 4000)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to execute the pathfinding operation.
|
||||
*/
|
||||
public LiquidPathFinder2D init(Vector3 startNode)
|
||||
{
|
||||
this.findNodes(startNode);
|
||||
if (this.fill && this.isValidNode(startNode))
|
||||
{
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiquidPathFinder2D reset()
|
||||
{
|
||||
this.nodes.clear();
|
||||
this.results.clear();
|
||||
return this;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue