Fixed pump not filling area at all
Still need to rework the method to fix a few other issues
This commit is contained in:
parent
24645491a8
commit
835ae8a047
2 changed files with 14 additions and 21 deletions
|
@ -39,12 +39,12 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
private List<Vector3> targetSources = new ArrayList<Vector3>();
|
private List<Vector3> targetSources = new ArrayList<Vector3>();
|
||||||
private List<Vector3> updateQue = new ArrayList<Vector3>();
|
private List<Vector3> updateQue = new ArrayList<Vector3>();
|
||||||
private LiquidPathFinder pathLiquid;
|
private LiquidPathFinder pathLiquid;
|
||||||
|
|
||||||
public LiquidPathFinder getLiquidFinder()
|
public LiquidPathFinder getLiquidFinder()
|
||||||
{
|
{
|
||||||
if(pathLiquid == null)
|
if (pathLiquid == null)
|
||||||
{
|
{
|
||||||
pathLiquid = new LiquidPathFinder(this.worldObj, false, 1000, 100);
|
pathLiquid = new LiquidPathFinder(this.worldObj, 1000, 100);
|
||||||
}
|
}
|
||||||
return pathLiquid;
|
return pathLiquid;
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,9 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
*/
|
*/
|
||||||
public void getNextFluidBlock()
|
public void getNextFluidBlock()
|
||||||
{
|
{
|
||||||
|
|
||||||
getLiquidFinder().reset();
|
getLiquidFinder().reset();
|
||||||
getLiquidFinder().init(new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ));
|
getLiquidFinder().init(new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ), false);
|
||||||
// System.out.println("Nodes:" + pathFinder.nodes.size() + "Results:" +
|
// System.out.println("Nodes:" + pathFinder.nodes.size() + "Results:" +
|
||||||
// pathFinder.results.size());
|
// pathFinder.results.size());
|
||||||
for (Vector3 vec : getLiquidFinder().nodes)
|
for (Vector3 vec : getLiquidFinder().nodes)
|
||||||
|
@ -348,10 +348,11 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
|
|
||||||
int blocks = (resource.amount / LiquidContainerRegistry.BUCKET_VOLUME);
|
int blocks = (resource.amount / LiquidContainerRegistry.BUCKET_VOLUME);
|
||||||
|
|
||||||
/* FIND ALL VALID BLOCKS ON LEVEL OR BELLOW */
|
/* FIND ALL VALID BLOCKS ON LEVEL OR BELLOW */
|
||||||
final Vector3 faceVec = new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ);
|
final Vector3 faceVec = new Vector3(this.xCoord + this.getFacing().offsetX, this.yCoord + this.getFacing().offsetY, this.zCoord + this.getFacing().offsetZ);
|
||||||
getLiquidFinder().init(faceVec);
|
getLiquidFinder().init(faceVec, true);
|
||||||
|
//System.out.println("Drain:FillArea: Targets -> " + getLiquidFinder().results.size());
|
||||||
|
|
||||||
/* SORT RESULTS TO PUT THE LOWEST AND CLOSEST AT THE TOP */
|
/* SORT RESULTS TO PUT THE LOWEST AND CLOSEST AT THE TOP */
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -386,11 +387,9 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("FluidMech: Error sorting fill collection \n");
|
System.out.println("FluidMech: Error sorting fill collection");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
/* START FILLING IN OR CHECKING IF CAN FILL AREA */
|
|
||||||
int fillable = 0;
|
|
||||||
for (Vector3 loc : getLiquidFinder().results)
|
for (Vector3 loc : getLiquidFinder().results)
|
||||||
{
|
{
|
||||||
if (blocks <= 0)
|
if (blocks <= 0)
|
||||||
|
@ -400,7 +399,6 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
LiquidStack stack = FluidHelper.getLiquidFromBlockId(loc.getBlockID(worldObj));
|
LiquidStack stack = FluidHelper.getLiquidFromBlockId(loc.getBlockID(worldObj));
|
||||||
if (stack != null && stack.isLiquidEqual(resource) && loc.getBlockMetadata(worldObj) != 0)
|
if (stack != null && stack.isLiquidEqual(resource) && loc.getBlockMetadata(worldObj) != 0)
|
||||||
{
|
{
|
||||||
fillable++;
|
|
||||||
drained += LiquidContainerRegistry.BUCKET_VOLUME;
|
drained += LiquidContainerRegistry.BUCKET_VOLUME;
|
||||||
blocks--;
|
blocks--;
|
||||||
if (doFill)
|
if (doFill)
|
||||||
|
@ -424,7 +422,6 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
||||||
}
|
}
|
||||||
if (loc.getBlockID(worldObj) == 0)
|
if (loc.getBlockID(worldObj) == 0)
|
||||||
{
|
{
|
||||||
fillable++;
|
|
||||||
drained += LiquidContainerRegistry.BUCKET_VOLUME;
|
drained += LiquidContainerRegistry.BUCKET_VOLUME;
|
||||||
blocks--;
|
blocks--;
|
||||||
if (doFill)
|
if (doFill)
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class LiquidPathFinder
|
||||||
* OVER
|
* OVER
|
||||||
*/
|
*/
|
||||||
public List<Vector3> results = new ArrayList<Vector3>();/* LOCATIONS THAT ARE VALID RESULTS */
|
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 boolean fill = false; /* ARE WE FILLING THE PATH OR DRAINING THE PATH */
|
||||||
private ForgeDirection priority; /* BASED ON fill -- WHICH DIRECTION WILL THE PATH GO FIRST */
|
private ForgeDirection priority; /* BASED ON fill -- WHICH DIRECTION WILL THE PATH GO FIRST */
|
||||||
private int resultLimit = 2000;
|
private int resultLimit = 2000;
|
||||||
private Vector2 Start;
|
private Vector2 Start;
|
||||||
|
@ -32,11 +32,10 @@ public class LiquidPathFinder
|
||||||
private Random random = new Random();
|
private Random random = new Random();
|
||||||
List<ForgeDirection> bn = new ArrayList<ForgeDirection>();
|
List<ForgeDirection> bn = new ArrayList<ForgeDirection>();
|
||||||
|
|
||||||
public LiquidPathFinder(final World world, final boolean fill, final int resultLimit, final double range)
|
public LiquidPathFinder(final World world, final int resultLimit, final double range)
|
||||||
{
|
{
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.fill = fill;
|
|
||||||
if (fill)
|
if (fill)
|
||||||
{
|
{
|
||||||
priority = ForgeDirection.DOWN;
|
priority = ForgeDirection.DOWN;
|
||||||
|
@ -153,14 +152,11 @@ public class LiquidPathFinder
|
||||||
/**
|
/**
|
||||||
* Called to execute the pathfinding operation.
|
* Called to execute the pathfinding operation.
|
||||||
*/
|
*/
|
||||||
public LiquidPathFinder init(final Vector3 startNode)
|
public LiquidPathFinder init(final Vector3 startNode, final boolean fill)
|
||||||
{
|
{
|
||||||
this.Start = startNode.toVector2();
|
this.Start = startNode.toVector2();
|
||||||
|
this.fill = fill;
|
||||||
this.findNodes(startNode);
|
this.findNodes(startNode);
|
||||||
if (this.fill && this.isValidNode(startNode))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue