Example usage for net.minecraftforge.common.brewing BrewingRecipeRegistry getOutput

List of usage examples for net.minecraftforge.common.brewing BrewingRecipeRegistry getOutput

Introduction

In this page you can find the example usage for net.minecraftforge.common.brewing BrewingRecipeRegistry getOutput.

Prototype

public static ItemStack getOutput(ItemStack input, ItemStack ingredient) 

Source Link

Document

Returns the output ItemStack obtained by brewing the passed input and ingredient.

Usage

From source file:com.github.liachmodded.uhcreloaded.forge.rule.CancelPotionBrewing.java

License:Open Source License

@SubscribeEvent
public void cancelCertainPotionBrewing(PotionBrewEvent.Pre evt) {
    ItemStack modifier = evt.getItem(3);
    for (int i = 0; i < evt.getLength(); i++) {
        ItemStack stack = evt.getItem(i);
        if (!stack.isEmpty()) {
            ItemStack output = BrewingRecipeRegistry.getOutput(stack, modifier);
            if (output.getItem() instanceof ItemPotion) {
                if (!ConfigHandler.allowBrewingPotionSplash && output.getItem() instanceof ItemSplashPotion) {
                    evt.setCanceled(true);
                    return;
                }//from   w w w.j a  v a 2s .  com
                if (!ConfigHandler.allowBrewingPotionLingering
                        && output.getItem() instanceof ItemLingeringPotion) {
                    evt.setCanceled(true);
                    return;
                }
                List<PotionEffect> potionEffects = PotionUtils.getEffectsFromStack(output);
                for (PotionEffect effect : potionEffects) {
                    if (effect.getAmplifier() > ConfigHandler.brewingPotionMaxLevel) {
                        evt.setCanceled(true);
                        return;
                    }
                    if (!ConfigHandler.allowBrewingPotionRegen
                            && effect.getPotion() == MobEffects.REGENERATION) {
                        evt.setCanceled(true);
                        return;
                    }
                }
            }
        }
    }
}

From source file:com.lothrazar.cyclicmagic.registry.RecipeRegistry.java

License:Open Source License

/**
 * Currently not used but it does work./*from   www .  j a va2 s  .co m*/
 * 
 * has built in unit test
 * 
 * @param input
 * @param ingredient
 * @param output
 * @return
 */
public static BrewingRecipe addBrewingRecipe(ItemStack input, ItemStack ingredient, ItemStack output) {
    if (input.isEmpty() || input.getItem() == null) {
        return null;
    }
    BrewingRecipe recipe = new BrewingRecipe(input, ingredient, output);
    BrewingRecipeRegistry.addRecipe(recipe);
    if (ModCyclic.logger.runUnitTests()) {//OMG UNIT TESTING WAAT
        ItemStack output0 = BrewingRecipeRegistry.getOutput(input, ingredient);
        if (output0.getItem() == output.getItem())
            ModCyclic.logger.logTestResult(
                    "Brewing Recipe succefully registered and working: " + output.getTranslationKey());
        else {
            ModCyclic.logger.logTestResult("Brewing Recipe FAILED to register" + output.getTranslationKey());
        }
    }
    return recipe;
}