Last min additions
Added path finder to get highest water source block with in 10K block process Added Vars for max drain for drain and pump. Pump will have a gui setting for this later and drain a config option Added PatherFinder for finding highest block of an ID
This commit is contained in:
parent
21e340dd9d
commit
e69c046ad4
4 changed files with 81 additions and 20 deletions
|
@ -15,12 +15,6 @@ import universalelectricity.core.path.IPathCallBack;
|
|||
import universalelectricity.core.path.Pathfinder;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* Check if a conductor connects with another.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class PathfinderCheckerLiquid extends Pathfinder
|
||||
{
|
||||
public PathfinderCheckerLiquid(final World world, final int maxResources, final LiquidStack resource, final Vector3... ignoreList)
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package fluidmech.common.pump;
|
||||
|
||||
import fluidmech.common.FluidMech;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import universalelectricity.core.path.IPathCallBack;
|
||||
import universalelectricity.core.path.Pathfinder;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class PathfinderFindHighestBlock extends Pathfinder
|
||||
{
|
||||
public static int highestY = 0;
|
||||
|
||||
public PathfinderFindHighestBlock(final World world, final int blockID, final Vector3... ignoreList)
|
||||
{
|
||||
super(new IPathCallBack()
|
||||
{
|
||||
@Override
|
||||
public Set<Vector3> getConnectedNodes(Pathfinder finder, Vector3 currentNode)
|
||||
{
|
||||
Set<Vector3> neighbors = new HashSet<Vector3>();
|
||||
Vector3 pos = currentNode.clone().modifyPositionFromSide(ForgeDirection.UP);
|
||||
if (pos.getBlockID(world) == blockID)
|
||||
{
|
||||
neighbors.add(pos);
|
||||
if (pos.intY() > highestY)
|
||||
{
|
||||
highestY = pos.intY();
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
pos = currentNode.clone().modifyPositionFromSide(direction);
|
||||
|
||||
if (pos.getBlockID(world) == blockID)
|
||||
{
|
||||
neighbors.add(pos);
|
||||
if (pos.intY() > highestY)
|
||||
{
|
||||
highestY = pos.intY();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearch(Pathfinder finder, Vector3 node)
|
||||
{
|
||||
if (finder.closedSet.size() >= 10000 || highestY == 256)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.highestY = 0;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
private ForgeDirection inputSide = ForgeDirection.UNKNOWN;
|
||||
/* Fake Internal Tank */
|
||||
private LiquidTank fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
private int liquidRequest = 1;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
|
@ -42,7 +43,7 @@ public class TileEntityConstructionPump extends TileEntityElectricityRunnable im
|
|||
{
|
||||
if (tank instanceof TileEntityDrain)
|
||||
{
|
||||
((TileEntityDrain) tank).requestLiquid(this, new LiquidStack(-1, LiquidContainerRegistry.BUCKET_VOLUME));
|
||||
((TileEntityDrain) tank).requestLiquid(this, new LiquidStack(-1, liquidRequest * LiquidContainerRegistry.BUCKET_VOLUME));
|
||||
called = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
{
|
||||
private ForgeDirection face = ForgeDirection.UNKNOWN;
|
||||
private boolean drainSources = true;
|
||||
|
||||
/* MAX BLOCKS DRAINED PER 1/2 SECOND */
|
||||
public static int MAX_DRAIN_PER_PROCESS = 30;
|
||||
/* LIST OF PUMPS AND THERE REQUESTS FOR THIS DRAIN */
|
||||
private HashMap<TileEntityConstructionPump, LiquidStack> requestMap = new HashMap<TileEntityConstructionPump, LiquidStack>();
|
||||
|
||||
|
@ -52,7 +53,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
int blocksDrained = 0;
|
||||
for (Vector3 loc : targetSources)
|
||||
{
|
||||
if (blocksDrained >= 5 && FluidHelper.isStillLiquid(this.worldObj, loc))
|
||||
if (blocksDrained >= MAX_DRAIN_PER_PROCESS && FluidHelper.isStillLiquid(this.worldObj, loc))
|
||||
{
|
||||
LiquidStack stack = FluidHelper.getLiquidFromBlockId(loc.getBlockID(this.worldObj));
|
||||
if (stack != null)
|
||||
|
@ -132,17 +133,12 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
*/
|
||||
public void getNextFluidBlock()
|
||||
{
|
||||
int blockID = Block.waterStill.blockID;
|
||||
int y = this.yCoord + 1;
|
||||
while (blockID == Block.waterStill.blockID)
|
||||
{
|
||||
blockID = worldObj.getBlockId(xCoord, y, zCoord);
|
||||
if (blockID == Block.waterStill.blockID)
|
||||
{
|
||||
y++;
|
||||
}
|
||||
|
||||
}
|
||||
/* FIND HIGHEST DRAIN POINT FIRST */
|
||||
PathfinderFindHighestBlock path = new PathfinderFindHighestBlock(this.worldObj, Block.waterStill.blockID);
|
||||
path.init(new Vector3(xCoord + this.face.offsetX, yCoord + this.face.offsetY, zCoord + this.face.offsetZ));
|
||||
int y = path.highestY;
|
||||
|
||||
/* FIND 10 UNMARKED SOURCES */
|
||||
PathfinderCheckerLiquid pathFinder = new PathfinderCheckerLiquid(worldObj, 10, null, (Vector3[]) this.targetSources.toArray());
|
||||
pathFinder.init(new Vector3(xCoord, y, zCoord));
|
||||
for (Vector3 loc : pathFinder.closedSet)
|
||||
|
|
Loading…
Reference in a new issue