Search in sources :

Example 1 with CrudeBurningRecipe

use of com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe in project createaddition by mrh0.

the class CrudeBurningCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, CrudeBurningRecipe recipe, IIngredients ingredients) {
    IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
    NonNullList<FluidIngredient> fluidIngredients = NonNullList.of(recipe.getFluidIngredient());
    List<FluidStack> out = new ArrayList<FluidStack>();
    fluidStacks.init(0, true, 81, 7);
    fluidStacks.set(0, withImprovedVisibility(recipe.getFluidIngredient().getMatchingFluidStacks().stream().map(fluid -> {
        out.add(fluid);
        return fluid;
    }).collect(Collectors.toList())));
    addFluidTooltip(fluidStacks, fluidIngredients, out);
}
Also used : IGuiFluidStackGroup(mezz.jei.api.gui.ingredient.IGuiFluidStackGroup) IIngredients(mezz.jei.api.ingredients.IIngredients) Collectors(java.util.stream.Collectors) AllGuiTextures(com.simibubi.create.foundation.gui.AllGuiTextures) ArrayList(java.util.ArrayList) PoseStack(com.mojang.blaze3d.vertex.PoseStack) Ingredient(net.minecraft.world.item.crafting.Ingredient) List(java.util.List) FluidIngredient(com.simibubi.create.foundation.fluid.FluidIngredient) Minecraft(net.minecraft.client.Minecraft) CrudeBurningRecipe(com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe) NonNullList(net.minecraft.core.NonNullList) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.world.item.ItemStack) VanillaTypes(mezz.jei.api.constants.VanillaTypes) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) CABlocks(com.mrh0.createaddition.index.CABlocks) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) FluidIngredient(com.simibubi.create.foundation.fluid.FluidIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) IGuiFluidStackGroup(mezz.jei.api.gui.ingredient.IGuiFluidStackGroup) ArrayList(java.util.ArrayList)

Example 2 with CrudeBurningRecipe

use of com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe in project createaddition by mrh0.

the class CrudeBurner method use.

@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
    if (world.isClientSide())
        return InteractionResult.SUCCESS;
    BlockEntity tileentity = world.getBlockEntity(pos);
    if (tileentity instanceof CrudeBurnerTileEntity) {
        CrudeBurnerTileEntity cbte = (CrudeBurnerTileEntity) tileentity;
        ItemStack held = player.getMainHandItem();
        if (!(held.getItem() instanceof BucketItem))
            return InteractionResult.CONSUME;
        LazyOptional<IFluidHandlerItem> cap = held.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
        if (!cap.isPresent())
            return InteractionResult.CONSUME;
        IFluidHandlerItem handler = cap.orElse(null);
        if (handler.getFluidInTank(0).isEmpty())
            return InteractionResult.CONSUME;
        FluidStack stack = handler.getFluidInTank(0);
        Optional<CrudeBurningRecipe> recipe = cbte.find(stack, world);
        if (!recipe.isPresent())
            return InteractionResult.CONSUME;
        LazyOptional<IFluidHandler> tecap = cbte.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY);
        if (!tecap.isPresent())
            return InteractionResult.CONSUME;
        IFluidHandler tehandler = tecap.orElse(null);
        if (tehandler.getTankCapacity(0) - tehandler.getFluidInTank(0).getAmount() < 1000)
            return InteractionResult.CONSUME;
        tehandler.fill(new FluidStack(handler.getFluidInTank(0).getFluid(), 1000), FluidAction.EXECUTE);
        if (!player.isCreative())
            player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.BUCKET, 1));
        player.playSound(SoundEvents.BUCKET_EMPTY, 1f, 1f);
    }
    return InteractionResult.CONSUME;
}
Also used : IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) FluidStack(net.minecraftforge.fluids.FluidStack) BucketItem(net.minecraft.world.item.BucketItem) CrudeBurningRecipe(com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe) ItemStack(net.minecraft.world.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) AbstractBurnerBlockEntity(com.mrh0.createaddition.blocks.base.AbstractBurnerBlockEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) AbstractFurnaceBlockEntity(net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity)

Aggregations

CrudeBurningRecipe (com.mrh0.createaddition.recipe.crude_burning.CrudeBurningRecipe)2 ItemStack (net.minecraft.world.item.ItemStack)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 AbstractBurnerBlockEntity (com.mrh0.createaddition.blocks.base.AbstractBurnerBlockEntity)1 CABlocks (com.mrh0.createaddition.index.CABlocks)1 FluidIngredient (com.simibubi.create.foundation.fluid.FluidIngredient)1 AllGuiTextures (com.simibubi.create.foundation.gui.AllGuiTextures)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 VanillaTypes (mezz.jei.api.constants.VanillaTypes)1 IRecipeLayout (mezz.jei.api.gui.IRecipeLayout)1 IGuiFluidStackGroup (mezz.jei.api.gui.ingredient.IGuiFluidStackGroup)1 IIngredients (mezz.jei.api.ingredients.IIngredients)1 Minecraft (net.minecraft.client.Minecraft)1 NonNullList (net.minecraft.core.NonNullList)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 BucketItem (net.minecraft.world.item.BucketItem)1 Ingredient (net.minecraft.world.item.crafting.Ingredient)1