Fix refineries running constantly.

Power pipes dissipate stored energy if none is input.
This commit is contained in:
Christian 2012-11-14 23:24:11 -05:00
parent 15bcb22032
commit 042067483d
5 changed files with 46 additions and 25 deletions

View file

@ -145,7 +145,7 @@ public class BuildCraftEnergy {
bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc);
LanguageRegistry.addName(bucketFuel, "Fuel Bucket");
RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 10, 1));
RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 12, 1));
// Iron Engine Fuels
IronEngineFuel.fuels.add(new IronEngineFuel(Block.lavaStill.blockID, 1, 20000));

View file

@ -67,8 +67,10 @@ public abstract class Engine {
public void update() {
if (!tile.isRedstonePowered) {
if (energy > 1) {
if (energy >= 1) {
energy -= 1;
} else if (energy < 1) {
energy = 0;
}
}
}

View file

@ -166,7 +166,9 @@ public class EngineIron extends Engine {
}
if (heat <= 0 && penaltyCooling > 0) {
if (heat <= 0) heat = 0;
if (heat == 0 && penaltyCooling > 0) {
penaltyCooling--;
}
}
@ -239,24 +241,34 @@ public class EngineIron extends Engine {
public void getGUINetworkData(int i, int j) {
switch (i) {
case 0:
energy = j / 10;
int iEnergy = Math.round(energy * 10);
iEnergy = (iEnergy & 0xff00) | (j & 0xff);
energy = iEnergy / 10;
break;
case 1:
currentOutput = j / 10;
iEnergy = Math.round(energy * 10);
iEnergy = (iEnergy & 0xff) | ((j & 0xff) << 8);
energy = iEnergy / 10;
break;
case 2:
heat = j;
currentOutput = j / 10;
break;
case 3:
liquidQty = j;
heat = (heat & 0xff00) | (j & 0xff);
break;
case 4:
liquidId = j;
heat = (heat & 0xff) | ((j & 0xff) << 8 );
break;
case 5:
coolantQty = j;
liquidQty = j;
break;
case 6:
liquidId = j;
break;
case 7:
coolantQty = j;
break;
case 8:
coolantId = j;
break;
}
@ -264,13 +276,15 @@ public class EngineIron extends Engine {
@Override
public void sendGUINetworkData(ContainerEngine containerEngine, ICrafting iCrafting) {
iCrafting.updateCraftingInventoryInfo(containerEngine, 0, Math.round(energy * 10));
iCrafting.updateCraftingInventoryInfo(containerEngine, 1, Math.round(currentOutput * 10));
iCrafting.updateCraftingInventoryInfo(containerEngine, 2, heat);
iCrafting.updateCraftingInventoryInfo(containerEngine, 3, liquidQty);
iCrafting.updateCraftingInventoryInfo(containerEngine, 4, liquidId);
iCrafting.updateCraftingInventoryInfo(containerEngine, 5, coolantQty);
iCrafting.updateCraftingInventoryInfo(containerEngine, 6, coolantId);
iCrafting.updateCraftingInventoryInfo(containerEngine, 0, Math.round(energy * 10) & 0xff);
iCrafting.updateCraftingInventoryInfo(containerEngine, 1, (Math.round(energy * 10) & 0xff00) >> 8 );
iCrafting.updateCraftingInventoryInfo(containerEngine, 2, Math.round(currentOutput * 10));
iCrafting.updateCraftingInventoryInfo(containerEngine, 3, heat & 0xff);
iCrafting.updateCraftingInventoryInfo(containerEngine, 4, (heat & 0xff00) >> 8);
iCrafting.updateCraftingInventoryInfo(containerEngine, 5, liquidQty);
iCrafting.updateCraftingInventoryInfo(containerEngine, 6, liquidId);
iCrafting.updateCraftingInventoryInfo(containerEngine, 7, coolantQty);
iCrafting.updateCraftingInventoryInfo(containerEngine, 8, coolantId);
}
@Override

View file

@ -167,7 +167,10 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
public void updateEntity() {
if (CoreProxy.proxy.isRenderWorld(worldObj)) {
simpleAnimationIterate();
return;
} else if (CoreProxy.proxy.isSimulating(worldObj) && updateNetworkTime.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
System.out.printf("Server Anim state: %d %f\n", animationStage, animationSpeed);
sendNetworkUpdate();
}
@ -192,30 +195,27 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
return;
}
if (!containsInput(currentRecipe.ingredient1) || !containsInput(currentRecipe.ingredient2)) {
decreaseAnimation();
return;
}
isActive = true;
if (powerProvider.getEnergyStored() >= currentRecipe.energy) {
increaseAnimation();
} else {
decreaseAnimation();
return;
}
if (!time.markTimeIfDelay(worldObj, currentRecipe.delay)) {
return;
}
if (!containsInput(currentRecipe.ingredient1)
|| !containsInput(currentRecipe.ingredient2)) {
decreaseAnimation();
return;
}
float energyUsed = powerProvider.useEnergy(currentRecipe.energy, currentRecipe.energy, true);
if (energyUsed != 0) {
if (consumeInput(currentRecipe.ingredient1)
&& consumeInput(currentRecipe.ingredient2)) {
if (consumeInput(currentRecipe.ingredient1) && consumeInput(currentRecipe.ingredient2)) {
result.liquidId = currentRecipe.result.itemID;
result.quantity += currentRecipe.result.amount;
}

View file

@ -183,6 +183,11 @@ public class PipeTransportPower extends PipeTransport {
double[] next = Arrays.copyOf(internalPower, 6);
internalPower = internalNextPower;
internalNextPower = next;
for (int i = 0; i < nextPowerQuery.length; i++) {
if (powerQuery[i] == 0.0d) {
internalNextPower[i]-=1;
}
}
}
}