use of gregtech.api.recipes.recipes.PrimitiveBlastFurnaceRecipe in project GregTech by GregTechCE.
the class MetaTileEntityPrimitiveBlastFurnace method tryPickNewRecipe.
private boolean tryPickNewRecipe() {
ItemStack inputStack = importItems.getStackInSlot(0);
ItemStack fuelStack = importItems.getStackInSlot(1);
if (inputStack.isEmpty() || (fuelStack.isEmpty() && fuelUnitsLeft == 0)) {
return false;
}
float fuelUnitsPerItem = getFuelUnits(fuelStack);
float totalFuelUnits = fuelUnitsLeft + fuelUnitsPerItem * fuelStack.getCount();
PrimitiveBlastFurnaceRecipe currentRecipe = getOrRefreshRecipe(inputStack);
if (currentRecipe != null && setupRecipe(inputStack, (int) totalFuelUnits, currentRecipe)) {
inputStack.shrink(currentRecipe.getInput().getCount());
float fuelUnitsToConsume = currentRecipe.getFuelAmount();
float remainderConsumed = Math.min(fuelUnitsToConsume, fuelUnitsLeft);
fuelUnitsToConsume -= remainderConsumed;
int fuelItemsToConsume = (int) Math.ceil(fuelUnitsToConsume / (fuelUnitsPerItem * 1.0));
float remainderAdded = fuelItemsToConsume * fuelUnitsPerItem - fuelUnitsToConsume;
this.fuelUnitsLeft += (remainderAdded - remainderConsumed);
fuelStack.shrink(fuelItemsToConsume);
this.maxProgressDuration = currentRecipe.getDuration();
this.currentProgress = 0;
NonNullList<ItemStack> outputs = NonNullList.create();
outputs.add(currentRecipe.getOutput().copy());
outputs.add(getAshForRecipeFuelConsumption(currentRecipe.getFuelAmount()));
this.outputsList = outputs;
markDirty();
return true;
}
return false;
}
use of gregtech.api.recipes.recipes.PrimitiveBlastFurnaceRecipe in project GregTech by GregTechCE.
the class PBFRecipeBuilder method buildAndRegister.
@ZenMethod
public void buildAndRegister() {
ValidationResult<PrimitiveBlastFurnaceRecipe> result = build();
if (result.getType() == EnumValidationResult.VALID) {
PrimitiveBlastFurnaceRecipe recipe = result.getResult();
RecipeMaps.PRIMITIVE_BLAST_FURNACE_RECIPES.add(recipe);
}
}
Aggregations