List of usage examples for net.minecraftforge.event.brewing PotionBrewEvent.Pre getLength
public int getLength()
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; }/* ww w . ja va 2 s. 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; } } } } } }