Self-merged Chemical Infuser fix

This commit is contained in:
Aidan C. Brady 2015-03-20 22:54:48 -05:00
parent 39621a74b1
commit 81b5724c53
4 changed files with 39 additions and 19 deletions

View file

@ -37,25 +37,32 @@ public class ChemicalPairInput extends MachineInput<ChemicalPairInput>
public ChemicalPairInput() {}
public boolean useGas(GasTank leftTank, GasTank rightTank, boolean deplete)
public boolean useGas(GasTank leftTank, GasTank rightTank, boolean deplete, int scale)
{
int leftAmount = leftGas.amount * scale;
int rightAmount = rightGas.amount * scale;
if(leftTank.canDraw(leftGas.getGas()) && rightTank.canDraw(rightGas.getGas()))
{
if(leftTank.getStored() >= leftGas.amount && rightTank.getStored() >= rightGas.amount)
if(leftTank.getStored() >= leftAmount && rightTank.getStored() >= rightAmount)
{
leftTank.draw(leftGas.amount, deplete);
rightTank.draw(rightGas.amount, deplete);
leftTank.draw(leftAmount, deplete);
rightTank.draw(rightAmount, deplete);
return true;
}
} else if(leftTank.canDraw(rightGas.getGas()) && rightTank.canDraw(leftGas.getGas()))
}
else if(leftTank.canDraw(rightGas.getGas()) && rightTank.canDraw(leftGas.getGas()))
{
if(leftTank.getStored() >= rightGas.amount && rightTank.getStored() >= leftGas.amount)
if(leftTank.getStored() >= rightAmount && rightTank.getStored() >= leftAmount)
{
leftTank.draw(rightGas.amount, deplete);
rightTank.draw(leftGas.amount, deplete);
leftTank.draw(rightAmount, deplete);
rightTank.draw(leftAmount, deplete);
return true;
}
}
return false;
}

View file

@ -17,6 +17,7 @@ public class ChemicalInfuserRecipe extends MachineRecipe<ChemicalPairInput, GasO
this(new ChemicalPairInput(leftInput, rightInput), new GasOutput(output));
}
@Override
public ChemicalInfuserRecipe copy()
{
return new ChemicalInfuserRecipe(getInput().copy(), getOutput().copy());
@ -24,14 +25,14 @@ public class ChemicalInfuserRecipe extends MachineRecipe<ChemicalPairInput, GasO
public boolean canOperate(GasTank leftTank, GasTank rightTank, GasTank outputTank)
{
return getInput().useGas(leftTank, rightTank, false) && getOutput().applyOutputs(outputTank, false, 1);
return getInput().useGas(leftTank, rightTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1);
}
public void operate(GasTank leftInput, GasTank rightInput, GasTank outputTank)
public void operate(GasTank leftInput, GasTank rightInput, GasTank outputTank, int scale)
{
if(getInput().useGas(leftInput, rightInput, true))
if(getInput().useGas(leftInput, rightInput, true, scale))
{
getOutput().applyOutputs(outputTank, true, 1);
getOutput().applyOutputs(outputTank, true, scale);
}
}
}

View file

@ -64,14 +64,17 @@ public class ChanceOutput extends MachineOutput<ChanceOutput>
inventory[primaryIndex] = primaryOutput.copy();
}
return true;
} else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].stackSize + primaryOutput.stackSize <= inventory[primaryIndex].getMaxStackSize())
}
else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].stackSize + primaryOutput.stackSize <= inventory[primaryIndex].getMaxStackSize())
{
if(doEmit)
{
inventory[primaryIndex].stackSize += primaryOutput.stackSize;
}
return true;
}
return false;
}
@ -83,21 +86,26 @@ public class ChanceOutput extends MachineOutput<ChanceOutput>
{
inventory[secondaryIndex] = secondaryOutput.copy();
}
return true;
} else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].stackSize + primaryOutput.stackSize <= inventory[secondaryIndex].getMaxStackSize())
}
else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].stackSize + primaryOutput.stackSize <= inventory[secondaryIndex].getMaxStackSize())
{
if(doEmit)
{
inventory[secondaryIndex].stackSize += secondaryOutput.stackSize;
}
return true;
}
return false;
}
return true;
}
@Override
public ChanceOutput copy()
{
return new ChanceOutput(StackUtils.copy(primaryOutput), StackUtils.copy(secondaryOutput), secondaryChance);

View file

@ -124,9 +124,9 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
if(canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this))
{
setActive(true);
setEnergy(getEnergy() - energyPerTick);
operate(recipe);
int operations = operate(recipe);
setEnergy(getEnergy() - energyPerTick*operations);
}
else {
if(prevEnergy >= getEnergy())
@ -196,11 +196,15 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
return recipe != null && recipe.canOperate(leftTank, rightTank, centerTank);
}
public void operate(ChemicalInfuserRecipe recipe)
public int operate(ChemicalInfuserRecipe recipe)
{
recipe.operate(leftTank, rightTank, centerTank);
int operations = getUpgradedUsage(recipe);
recipe.operate(leftTank, rightTank, centerTank, operations);
markDirty();
return operations;
}
@Override