Search in sources :

Example 1 with PotRecipe

use of net.dries007.tfc.common.recipes.PotRecipe in project TerraFirmaCraft by TerraFirmaCraft.

the class PotBlockEntity method handleCooking.

@Override
protected void handleCooking() {
    if (isBoiling()) {
        assert cachedRecipe != null;
        if (boilingTicks < cachedRecipe.getDuration()) {
            boilingTicks++;
            if (boilingTicks == 1)
                markForSync();
        } else {
            // Create output
            // Save the recipe here, as setting inventory will call setAndUpdateSlots, which will clear the cached recipe before output is created
            final PotRecipe recipe = cachedRecipe;
            final PotRecipe.Output output = recipe.getOutput(inventory);
            // Clear inputs
            inventory.tank.setFluid(FluidStack.EMPTY);
            for (int slot = SLOT_EXTRA_INPUT_START; slot <= SLOT_EXTRA_INPUT_END; slot++) {
                // Consume items, but set container items if they exist
                inventory.setStackInSlot(slot, inventory.getStackInSlot(slot).getContainerItem());
            }
            // Let the output handle filling into the empty pot
            output.onFinish(inventory);
            if (// Then, if we still have contents, save the output
            !output.isEmpty()) {
                this.output = output;
            }
            // Reset recipe progress
            cachedRecipe = null;
            boilingTicks = 0;
            updateCachedRecipe();
            markForSync();
        }
    } else if (// catch accidentally not syncing when it dips below temperature
    boilingTicks > 0) {
        boilingTicks = 0;
        markForSync();
    }
}
Also used : PotRecipe(net.dries007.tfc.common.recipes.PotRecipe)

Example 2 with PotRecipe

use of net.dries007.tfc.common.recipes.PotRecipe in project TerraFirmaCraft by TerraFirmaCraft.

the class SimplePotRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayoutBuilder builder, PotRecipe potRecipe, IFocusGroup focuses) {
    super.setRecipe(builder, potRecipe, focuses);
    SimplePotRecipe recipe = (SimplePotRecipe) potRecipe;
    FluidStack displayFluid = recipe.getDisplayFluid();
    if (!displayFluid.isEmpty()) {
        IRecipeSlotBuilder fluidOutput = builder.addSlot(RecipeIngredientRole.OUTPUT, 132, 26);
        fluidOutput.addIngredient(VanillaTypes.FLUID, displayFluid);
        fluidOutput.setFluidRenderer(1, false, 16, 16);
        fluidOutput.setSlotName("fluidOutput");
    }
    List<ItemStack> outputStacks = recipe.getOutputStacks();
    if (!outputStacks.isEmpty()) {
        // todo:  temporarily just adding the first output so JEI picks up the output stuff, we need to show up to all 5
        IRecipeSlotBuilder itemOutput = builder.addSlot(RecipeIngredientRole.OUTPUT, 132, 6);
        itemOutput.addItemStack(outputStacks.get(0));
        itemOutput.setSlotName("output1");
    }
}
Also used : SimplePotRecipe(net.dries007.tfc.common.recipes.SimplePotRecipe) FluidStack(net.minecraftforge.fluids.FluidStack) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

IRecipeSlotBuilder (mezz.jei.api.gui.builder.IRecipeSlotBuilder)1 PotRecipe (net.dries007.tfc.common.recipes.PotRecipe)1 SimplePotRecipe (net.dries007.tfc.common.recipes.SimplePotRecipe)1 ItemStack (net.minecraft.world.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1