Change how pump handles water.

Added config "consumeWater" which defaults to false. If false, pumps will not remove water source blocks if it detects more than 9 blocks of water in the area.

This should significantly reduce chunk rerenders and search cost (search terminates after 9 blocks). Essentially making a water pump nearly as computer friendly as an Aqueous Accumulator.
This commit is contained in:
CovertJaguar 2013-08-09 01:36:01 -07:00
parent 0ae4035dab
commit ae59a6cc88
2 changed files with 13 additions and 4 deletions

View file

@ -152,7 +152,7 @@ public class BuildCraftCore {
public static boolean loadDefaultRecipes = true;
public static boolean forcePneumaticPower = true;
public static boolean consumeWaterSources = true;
public static boolean consumeWaterSources = false;
public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length];
@ -220,9 +220,12 @@ public class BuildCraftCore {
Property diamondGearId = BuildCraftCore.mainConfiguration.getItem("diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID);
Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true);
modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)";
modifyWorld = modifyWorldProp.getBoolean(true);
Property consumeWater = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "consumeWater", consumeWaterSources);
consumeWaterSources = consumeWater.getBoolean(consumeWaterSources);
consumeWater.comment = "set to true if the Pump should consume water";
if(BuildCraftCore.modifyWorld) {
springBlock = new BlockSpring(springId.getInt()).setUnlocalizedName("eternalSpring");
CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class);

View file

@ -58,6 +58,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
private TileBuffer[] tileBuffer = null;
private SafeTimeTracker timer = new SafeTimeTracker();
private int tick = Utils.RANDOM.nextInt();
private int numFluidBlocksFound = 0;
public TilePump() {
powerHandler = new PowerHandler(this, Type.MACHINE);
@ -102,9 +103,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
if (isFluidAllowed(fluidToPump.getFluid()) && tank.fill(fluidToPump, false) == fluidToPump.amount) {
if (powerHandler.useEnergy(10, 10, true) == 10) {
index = getNextIndexToPump(true);
if (fluidToPump.getFluid() != FluidRegistry.WATER || BuildCraftCore.consumeWaterSources) {
if (fluidToPump.getFluid() != FluidRegistry.WATER || BuildCraftCore.consumeWaterSources || numFluidBlocksFound < 9) {
index = getNextIndexToPump(true);
BlockUtil.drainBlock(worldObj, index.x, index.y, index.z, true);
}
@ -215,6 +216,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
}
public void rebuildQueue() {
numFluidBlocksFound = 0;
pumpLayerQueues.clear();
int x = xCoord;
int y = aimY;
@ -244,6 +246,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
queueForPumping(index.x, index.y, index.z + 1, visitedBlocks, fluidsFound, pumpingFluid);
queueForPumping(index.x, index.y, index.z - 1, visitedBlocks, fluidsFound, pumpingFluid);
if (pumpingFluid == FluidRegistry.WATER && !BuildCraftCore.consumeWaterSources && numFluidBlocksFound >= 9)
return;
// if (System.nanoTime() > timeoutTime)
// return;
}
@ -262,6 +267,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
}
if (canDrainBlock(blockId, x, y, z, pumpingFluid)) {
getLayerQueue(y).add(index);
numFluidBlocksFound++;
}
}
}