Search in sources :

Example 1 with FluidIngredient

use of hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient in project AstralSorcery by HellFirePvP.

the class RenderPageRecipeTemplate method addInputInformation.

protected void addInputInformation(ItemStack stack, @Nullable Ingredient stackIngredient, List<ITextProperties> tooltip) {
    try {
        tooltip.addAll(stack.getTooltip(Minecraft.getInstance().player, Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL));
    } catch (Exception exc) {
        tooltip.add(new TranslationTextComponent("astralsorcery.misc.tooltipError").mergeStyle(TextFormatting.RED));
    }
    BookLookupInfo info = BookLookupRegistry.findPage(Minecraft.getInstance().player, LogicalSide.CLIENT, stack);
    if (info != null && info.canSee(ResearchHelper.getProgress(Minecraft.getInstance().player, LogicalSide.CLIENT)) && !info.getResearchNode().equals(this.getResearchNode())) {
        tooltip.add(StringTextComponent.EMPTY);
        tooltip.add(new TranslationTextComponent("astralsorcery.misc.craftInformation").mergeStyle(TextFormatting.GRAY));
    }
    if (stackIngredient != null && Minecraft.getInstance().gameSettings.advancedItemTooltips) {
        ITag<Item> itemTag = IngredientHelper.guessTag(stackIngredient);
        if (itemTag instanceof ITag.INamedTag) {
            tooltip.add(StringTextComponent.EMPTY);
            tooltip.add(new TranslationTextComponent("astralsorcery.misc.input.tag", ((ITag.INamedTag<Item>) itemTag).getName().toString()).mergeStyle(TextFormatting.GRAY));
        }
        if (stackIngredient instanceof FluidIngredient) {
            List<FluidStack> fluids = ((FluidIngredient) stackIngredient).getFluids();
            if (!fluids.isEmpty()) {
                ITextProperties cmp = null;
                for (FluidStack f : fluids) {
                    if (cmp == null) {
                        cmp = f.getFluid().getAttributes().getDisplayName(f);
                    } else {
                        cmp = new TranslationTextComponent("astralsorcery.misc.input.fluid.chain", cmp, f.getFluid().getAttributes().getDisplayName(f)).mergeStyle(TextFormatting.GRAY);
                    }
                }
                tooltip.add(StringTextComponent.EMPTY);
                tooltip.add(new TranslationTextComponent("astralsorcery.misc.input.fluid", cmp).mergeStyle(TextFormatting.GRAY));
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) FluidIngredient(hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) BookLookupInfo(hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 2 with FluidIngredient

use of hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient in project AstralSorcery by HellFirePvP.

the class ActiveSimpleAltarRecipe method consumeInputs.

public void consumeInputs(TileAltar altar) {
    TileInventory inv = altar.getInventory();
    AltarRecipeGrid grid = this.recipeToCraft.getInputs();
    for (int slot = 0; slot < AltarRecipeGrid.MAX_INVENTORY_SIZE; slot++) {
        Ingredient input = grid.getIngredient(slot);
        if (input instanceof FluidIngredient) {
            ItemStack stack = inv.getStackInSlot(slot);
            FluidActionResult far = FluidUtil.tryEmptyContainer(stack, VoidFluidHandler.INSTANCE, FluidAttributes.BUCKET_VOLUME, null, true);
            if (far.isSuccess()) {
                inv.setStackInSlot(slot, far.getResult());
            }
        } else {
            ItemUtils.decrementItem(inv, slot, altar::dropItemOnTop);
        }
    }
    for (CraftingFocusStack input : this.focusStacks) {
        TileSpectralRelay tar = MiscUtils.getTileAt(altar.getWorld(), input.getRealPosition(), TileSpectralRelay.class, true);
        if (tar != null) {
            TileInventory tarInventory = tar.getInventory();
            if (input.getInput() != null && input.getInput().getIngredient() instanceof FluidIngredient) {
                ItemStack stack = tarInventory.getStackInSlot(0);
                FluidActionResult far = FluidUtil.tryEmptyContainer(stack, VoidFluidHandler.INSTANCE, FluidAttributes.BUCKET_VOLUME, null, true);
                if (far.isSuccess()) {
                    tarInventory.setStackInSlot(0, far.getResult());
                }
            } else {
                ItemUtils.decrementItem(tarInventory, 0, altar::dropItemOnTop);
            }
        }
    }
}
Also used : FluidIngredient(hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient) Ingredient(net.minecraft.item.crafting.Ingredient) WrappedIngredient(hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient) FluidIngredient(hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient) TileSpectralRelay(hellfirepvp.astralsorcery.common.tile.TileSpectralRelay) TileInventory(hellfirepvp.astralsorcery.common.util.tile.TileInventory) ItemStack(net.minecraft.item.ItemStack) FluidActionResult(net.minecraftforge.fluids.FluidActionResult) CraftingFocusStack(hellfirepvp.astralsorcery.common.crafting.helper.CraftingFocusStack)

Aggregations

FluidIngredient (hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient)2 BookLookupInfo (hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo)1 CraftingFocusStack (hellfirepvp.astralsorcery.common.crafting.helper.CraftingFocusStack)1 WrappedIngredient (hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient)1 TileSpectralRelay (hellfirepvp.astralsorcery.common.tile.TileSpectralRelay)1 TileInventory (hellfirepvp.astralsorcery.common.util.tile.TileInventory)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 Ingredient (net.minecraft.item.crafting.Ingredient)1 ITextProperties (net.minecraft.util.text.ITextProperties)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1 FluidActionResult (net.minecraftforge.fluids.FluidActionResult)1 FluidStack (net.minecraftforge.fluids.FluidStack)1