Search in sources :

Example 1 with StateIngredient

use of vazkii.botania.api.recipe.StateIngredient in project Botania by VazkiiMods.

the class StateIngredientTagExcluding method serialize.

@Override
public JsonObject serialize() {
    JsonObject object = new JsonObject();
    object.addProperty("type", "tag_excluding");
    object.addProperty("tag", getTagId().toString());
    JsonArray array = new JsonArray();
    for (StateIngredient exclude : excludes) {
        array.add(exclude.serialize());
    }
    object.add("exclude", array);
    return object;
}
Also used : JsonArray(com.google.gson.JsonArray) StateIngredient(vazkii.botania.api.recipe.StateIngredient) JsonObject(com.google.gson.JsonObject)

Example 2 with StateIngredient

use of vazkii.botania.api.recipe.StateIngredient in project Botania by VazkiiMods.

the class PureDaisyRecipeCategory method setRecipe.

// todo fluid input rendering is probably kinda janky with waterlogged blocks. Might be worth getting rid of it entirely and only checking for full fluid blocks
@Override
public void setRecipe(@Nonnull IRecipeLayoutBuilder builder, @Nonnull IPureDaisyRecipe recipe, @Nonnull IFocusGroup focusGroup) {
    StateIngredient input = recipe.getInput();
    IRecipeSlotBuilder inputSlotBuilder = builder.addSlot(RecipeIngredientRole.INPUT, 9, 12).setFluidRenderer(1000, false, 16, 16);
    for (var state : input.getDisplayed()) {
        if (!state.getFluidState().isEmpty()) {
            inputSlotBuilder.addIngredient(VanillaTypes.FLUID, new FluidStack(state.getFluidState().getType(), 1000));
        }
    }
    inputSlotBuilder.addItemStacks(input.getDisplayedStacks()).addTooltipCallback((view, tooltip) -> tooltip.addAll(input.descriptionTooltip()));
    builder.addSlot(RecipeIngredientRole.CATALYST, 39, 12).addItemStack(new ItemStack(ModSubtiles.pureDaisy));
    Block outBlock = recipe.getOutputState().getBlock();
    FluidState outFluid = outBlock.defaultBlockState().getFluidState();
    if (!outFluid.isEmpty()) {
        builder.addSlot(RecipeIngredientRole.OUTPUT, 68, 12).setFluidRenderer(1000, false, 16, 16).addIngredient(VanillaTypes.FLUID, new FluidStack(outFluid.getType(), 1000));
    } else {
        if (outBlock.asItem() != Items.AIR) {
            builder.addSlot(RecipeIngredientRole.OUTPUT, 68, 12).addItemStack(new ItemStack(outBlock));
        }
    }
}
Also used : StateIngredient(vazkii.botania.api.recipe.StateIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) Block(net.minecraft.world.level.block.Block) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder) ItemStack(net.minecraft.world.item.ItemStack) FluidState(net.minecraft.world.level.material.FluidState)

Example 3 with StateIngredient

use of vazkii.botania.api.recipe.StateIngredient in project Botania by VazkiiMods.

the class ManaPoolREICategory method setupDisplay.

@Override
@Nonnull
public List<Widget> setupDisplay(ManaPoolREIDisplay display, Rectangle bounds) {
    List<Widget> widgets = new ArrayList<>();
    ItemStack pool = manaPool.getValue().copy();
    ItemNBTHelper.setBoolean(pool, "RenderFull", true);
    EntryStack<ItemStack> renderPool = EntryStacks.of(pool);
    Point center = new Point(bounds.getCenterX() - 8, bounds.getCenterY() - 14);
    widgets.add(Widgets.createRecipeBase(bounds));
    widgets.add(Widgets.createDrawableWidget(((helper, matrices, mouseX, mouseY, delta) -> {
        CategoryUtils.drawOverlay(helper, matrices, OVERLAY, center.x - 23, center.y - 13, 0, 0, 65, 44);
        HUDHandler.renderManaBar(matrices, center.x - 43, center.y + 37, 0x0000FF, 0.75F, display.getManaCost(), TilePool.MAX_MANA / 10);
    })));
    widgets.add(Widgets.createSlot(center).entry(renderPool).disableBackground());
    StateIngredient catalyst = display.getCatalyst();
    if (catalyst != null) {
        List<EntryStack<ItemStack>> entries = catalyst.getDisplayed().stream().map(state -> EntryStacks.of(state.getBlock())).collect(Collectors.toList());
        widgets.add(Widgets.createSlot(new Point(center.x - 50, center.y)).entries(entries).disableBackground());
    }
    widgets.add(Widgets.createSlot(new Point(center.x - 30, center.y)).entries(display.getInputEntries().get(0)).disableBackground());
    widgets.add(Widgets.createSlot(new Point(center.x + 29, center.y)).entries(display.getOutputEntries().get(0)).disableBackground());
    return widgets;
}
Also used : EntryStack(me.shedaniel.rei.api.common.entry.EntryStack) ResourceLocation(net.minecraft.resources.ResourceLocation) Rectangle(me.shedaniel.math.Rectangle) Renderer(me.shedaniel.rei.api.client.gui.Renderer) Component(net.minecraft.network.chat.Component) Widget(me.shedaniel.rei.api.client.gui.widgets.Widget) EntryStacks(me.shedaniel.rei.api.common.util.EntryStacks) ItemNBTHelper(vazkii.botania.common.helper.ItemNBTHelper) CategoryIdentifier(me.shedaniel.rei.api.common.category.CategoryIdentifier) DisplayCategory(me.shedaniel.rei.api.client.registry.display.DisplayCategory) ModBlocks(vazkii.botania.common.block.ModBlocks) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Point(me.shedaniel.math.Point) StateIngredient(vazkii.botania.api.recipe.StateIngredient) ResourceLocationHelper(vazkii.botania.common.lib.ResourceLocationHelper) List(java.util.List) TilePool(vazkii.botania.common.block.tile.mana.TilePool) ItemStack(net.minecraft.world.item.ItemStack) Nonnull(javax.annotation.Nonnull) Widgets(me.shedaniel.rei.api.client.gui.widgets.Widgets) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) HUDHandler(vazkii.botania.client.gui.HUDHandler) EntryStack(me.shedaniel.rei.api.common.entry.EntryStack) StateIngredient(vazkii.botania.api.recipe.StateIngredient) Widget(me.shedaniel.rei.api.client.gui.widgets.Widget) ArrayList(java.util.ArrayList) Point(me.shedaniel.math.Point) ItemStack(net.minecraft.world.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

StateIngredient (vazkii.botania.api.recipe.StateIngredient)3 ItemStack (net.minecraft.world.item.ItemStack)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Point (me.shedaniel.math.Point)1 Rectangle (me.shedaniel.math.Rectangle)1 Renderer (me.shedaniel.rei.api.client.gui.Renderer)1 Widget (me.shedaniel.rei.api.client.gui.widgets.Widget)1 Widgets (me.shedaniel.rei.api.client.gui.widgets.Widgets)1 DisplayCategory (me.shedaniel.rei.api.client.registry.display.DisplayCategory)1 CategoryIdentifier (me.shedaniel.rei.api.common.category.CategoryIdentifier)1 EntryStack (me.shedaniel.rei.api.common.entry.EntryStack)1 EntryStacks (me.shedaniel.rei.api.common.util.EntryStacks)1 IRecipeSlotBuilder (mezz.jei.api.gui.builder.IRecipeSlotBuilder)1 Component (net.minecraft.network.chat.Component)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1