use of buildcraft.api.recipes.IRefineryRecipeManager.ICoolableRecipe in project BuildCraft by BuildCraft.
the class TileHeatExchangeStart method craft.
private void craft() {
Tank c_in = tileEnd.tankCoolableIn;
Tank c_out = tankCoolableOut;
Tank h_in = tankHeatableIn;
Tank h_out = tileEnd.tankHeatableOut;
IRefineryRecipeManager reg = BuildcraftRecipeRegistry.refineryRecipes;
ICoolableRecipe c_recipe = reg.getCoolableRegistry().getRecipeForInput(c_in.getFluid());
IHeatableRecipe h_recipe = reg.getHeatableRegistry().getRecipeForInput(h_in.getFluid());
if (h_recipe == null || c_recipe == null) {
progressState = TileHeatExchange.EnumProgressState.STOPPING;
return;
}
if (c_recipe.heatFrom() <= h_recipe.heatFrom()) {
BCLog.logger.warn("Invalid heat values!");
progressState = TileHeatExchange.EnumProgressState.STOPPING;
return;
}
int c_diff = c_recipe.heatFrom() - c_recipe.heatTo();
int h_diff = h_recipe.heatTo() - h_recipe.heatFrom();
if (h_diff < 1 || c_diff < 1) {
throw new IllegalStateException("Invalid recipe " + c_recipe + ", " + h_recipe);
}
// TODO: Make mult the *maximum* multiplier, not the exact one.
int mult = FLUID_MULT[middles - 1];
boolean needs_c = heatProvided <= 0;
boolean needs_h = coolingProvided <= 0;
FluidStack c_in_f = setAmount(c_recipe.in(), mult);
FluidStack c_out_f = setAmount(c_recipe.out(), mult);
FluidStack h_in_f = setAmount(h_recipe.in(), mult);
FluidStack h_out_f = setAmount(h_recipe.out(), mult);
if (canFill(c_out, c_out_f) && canFill(h_out, h_out_f) && canDrain(c_in, c_in_f) && canDrain(h_in, h_in_f)) {
if (progressState == TileHeatExchange.EnumProgressState.OFF) {
progressState = TileHeatExchange.EnumProgressState.PREPARING;
} else if (progressState == TileHeatExchange.EnumProgressState.RUNNING) {
heatProvided--;
coolingProvided--;
if (needs_c) {
heatProvided += c_diff;
fill(c_out, c_out_f);
drain(c_in, c_in_f);
}
if (needs_h) {
coolingProvided += h_diff;
fill(h_out, h_out_f);
drain(h_in, h_in_f);
}
}
} else {
progressState = TileHeatExchange.EnumProgressState.STOPPING;
}
}
Aggregations