use of mezz.jei.api.recipe.IFocus in project HorsePower by GoryMoon.
the class ShapedChoppingCraftingWrapper method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
List<ItemStack> outputs = ingredients.getOutputs(ItemStack.class).get(0);
// determine the focused stack
IFocus<?> ifocus = recipeLayout.getFocus();
Object focusObj = ifocus.getValue();
// if the thing in focus is an itemstack
if (focusObj instanceof ItemStack) {
IGuiIngredientGroup<ItemStack> guiIngredients = recipeLayout.getIngredientsGroup(ItemStack.class);
ItemStack focus = (ItemStack) focusObj;
IFocus.Mode mode = ifocus.getMode();
// input means we clicked on an ingredient, make sure it is one that affects the base
if (mode == IFocus.Mode.INPUT && isOutputBlock(focus)) {
// first, get the output recipe
BlockHPChoppingBase block = (BlockHPChoppingBase) Block.getBlockFromItem(recipe.getSimpleRecipeOutput().getItem());
// then create a stack with the focus item (which we already validated above)
ItemStack outputFocus = BlockChopper.createItemStack(block, 1, focus);
// and finally, set the focus override for the recipe
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.OUTPUT, outputFocus));
} else // if we clicked the chopping block, remove all items which affect the base textures that are not the base item
if (mode == IFocus.Mode.OUTPUT) {
// so determine the base
ItemStack base = new ItemStack(focus.hasTagCompound() ? focus.getTagCompound().getCompoundTag("textureBlock") : new NBTTagCompound());
if (Block.getBlockFromItem(recipe.outputBlocks.get(0).getItem()) instanceof BlockHPChoppingBase) {
base = recipe.outputBlocks.get(0).copy();
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("textureBlock", focus.hasTagCompound() ? focus.getTagCompound().getCompoundTag("textureBlock") : new NBTTagCompound());
base.setTagCompound(tag);
}
if (!base.isEmpty()) {
// and loop through all slots removing leg affecting inputs which don't match
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.INPUT, base));
}
}
}
// add the itemstacks to the grid
HorsePowerPlugin.craftingGridHelper.setInputs(guiItemStacks, inputs, this.getWidth(), this.getHeight());
recipeLayout.getItemStacks().set(0, outputs);
}
use of mezz.jei.api.recipe.IFocus in project HorsePower by GoryMoon.
the class ShapelessChoppingCraftingWrapper method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, IIngredients ingredients) {
recipeLayout.setShapeless();
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
List<ItemStack> outputs = ingredients.getOutputs(ItemStack.class).get(0);
// determine the focused stack
IFocus<?> ifocus = recipeLayout.getFocus();
Object focusObj = ifocus.getValue();
// if the thing in focus is an itemstack
if (focusObj instanceof ItemStack) {
IGuiIngredientGroup<ItemStack> guiIngredients = recipeLayout.getIngredientsGroup(ItemStack.class);
ItemStack focus = (ItemStack) focusObj;
IFocus.Mode mode = ifocus.getMode();
// input means we clicked on an ingredient, make sure it is one that affects the base
if (mode == IFocus.Mode.INPUT && isOutputBlock(focus)) {
// first, get the output recipe
BlockHPChoppingBase block = (BlockHPChoppingBase) Block.getBlockFromItem(recipe.getSimpleRecipeOutput().getItem());
// then create a stack with the focus item (which we already validated above)
ItemStack outputFocus = BlockChopper.createItemStack(block, 1, focus);
// and finally, set the focus override for the recipe
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.OUTPUT, outputFocus));
} else // if we clicked the chopping block, remove all items which affect the base textures that are not the base item
if (mode == IFocus.Mode.OUTPUT) {
// so determine the base
ItemStack base = new ItemStack(focus.hasTagCompound() ? focus.getTagCompound().getCompoundTag("textureBlock") : new NBTTagCompound());
if (Block.getBlockFromItem(recipe.outputBlocks.get(0).getItem()) instanceof BlockHPChoppingBase) {
base = recipe.outputBlocks.get(0).copy();
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("textureBlock", focus.hasTagCompound() ? focus.getTagCompound().getCompoundTag("textureBlock") : new NBTTagCompound());
base.setTagCompound(tag);
}
if (!base.isEmpty()) {
// and loop through all slots removing leg affecting inputs which don't match
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.INPUT, base));
}
}
}
// add the itemstacks to the grid
HorsePowerPlugin.craftingGridHelper.setInputs(guiItemStacks, inputs);
recipeLayout.getItemStacks().set(0, outputs);
}
use of mezz.jei.api.recipe.IFocus in project HorsePower by GoryMoon.
the class ChoppingBlockCraftingWrapper method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
List<ItemStack> outputs = ingredients.getOutputs(ItemStack.class).get(0);
// determine the focused stack
IFocus<?> ifocus = recipeLayout.getFocus();
Object focusObj = ifocus.getValue();
// if the thing in focus is an itemstack
if (focusObj instanceof ItemStack) {
IGuiIngredientGroup<ItemStack> guiIngredients = recipeLayout.getIngredientsGroup(ItemStack.class);
ItemStack focus = (ItemStack) focusObj;
IFocus.Mode mode = ifocus.getMode();
// input means we clicked on an ingredient, make sure it is one that affects the legs
if (mode == IFocus.Mode.INPUT && isOutputBlock(focus)) {
// first, get the output recipe
BlockHPChoppingBase block = (BlockHPChoppingBase) Block.getBlockFromItem(recipe.getSimpleRecipeOutput().getItem());
// then create a stack with the focus item (which we already validated above)
ItemStack outputFocus = BlockChopper.createItemStack(block, Block.getBlockFromItem(focus.getItem()), focus.getItemDamage());
// and finally, set the focus override for the recipe
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.OUTPUT, outputFocus));
} else // if we clicked the table, remove all items which affect the legs textures that are not the leg item
if (mode == IFocus.Mode.OUTPUT) {
// so determine the legs
ItemStack base = new ItemStack(focus.hasTagCompound() ? focus.getTagCompound().getCompoundTag("textureBlock") : new NBTTagCompound());
if (!base.isEmpty()) {
// and loop through all slots removing leg affecting inputs which don't match
guiIngredients.setOverrideDisplayFocus(HorsePowerPlugin.recipeRegistry.createFocus(IFocus.Mode.INPUT, base));
}
}
}
// add the itemstacks to the grid
HorsePowerPlugin.craftingGridHelper.setInputs(guiItemStacks, inputs, this.getWidth(), this.getHeight());
recipeLayout.getItemStacks().set(0, outputs);
}
use of mezz.jei.api.recipe.IFocus in project GregTech by GregTechCEu.
the class JEIOptional method getWorldSceneRenderer.
@Optional.Method(modid = "jei")
public static WorldSceneRenderer getWorldSceneRenderer(MultiblockControllerBase controllerBase) {
IRecipeRegistry rr = GTJeiPlugin.jeiRuntime.getRecipeRegistry();
IFocus<ItemStack> focus = rr.createFocus(IFocus.Mode.INPUT, controllerBase.getStackForm());
return rr.getRecipeCategories(focus).stream().map(c -> (IRecipeCategory<IRecipeWrapper>) c).map(c -> rr.getRecipeWrappers(c, focus)).flatMap(List::stream).filter(MultiblockInfoRecipeWrapper.class::isInstance).findFirst().map(MultiblockInfoRecipeWrapper.class::cast).map(MultiblockInfoRecipeWrapper::getCurrentRenderer).orElse(null);
}
Aggregations