use of se.gory_moon.horsepower.blocks.BlockHPChoppingBase 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 se.gory_moon.horsepower.blocks.BlockHPChoppingBase 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 se.gory_moon.horsepower.blocks.BlockHPChoppingBase 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 se.gory_moon.horsepower.blocks.BlockHPChoppingBase in project HorsePower by GoryMoon.
the class ShapedChoppingRecipe method getRecipeOutput.
@Nonnull
@Override
public ItemStack getRecipeOutput() {
if (!outputBlocks.isEmpty() && !output.isEmpty()) {
ItemStack stack = outputBlocks.get(0).copy();
BlockHPChoppingBase block = (BlockHPChoppingBase) Block.getBlockFromItem(output.getItem());
int meta = stack.getMetadata();
if (meta == OreDictionary.WILDCARD_VALUE)
stack.setItemDamage(0);
return createItemStack(block, getSimpleRecipeOutput().getCount(), stack);
}
return super.getRecipeOutput();
}
use of se.gory_moon.horsepower.blocks.BlockHPChoppingBase in project HorsePower by GoryMoon.
the class ShapelessChoppingRecipe method getRecipeOutput.
@Nonnull
@Override
public ItemStack getRecipeOutput() {
if (!outputBlocks.isEmpty() && !output.isEmpty()) {
ItemStack stack = outputBlocks.get(0).copy();
BlockHPChoppingBase block = (BlockHPChoppingBase) Block.getBlockFromItem(output.getItem());
int meta = stack.getMetadata();
if (meta == OreDictionary.WILDCARD_VALUE)
stack.setItemDamage(0);
return createItemStack(block, getSimpleRecipeOutput().getCount(), stack);
}
return super.getRecipeOutput();
}
Aggregations