Search in sources :

Example 11 with ItemPotion

use of net.minecraft.item.ItemPotion in project MineFactoryReloaded by powercrystals.

the class TileEntityAutoBrewer method canBrew.

private boolean canBrew(int row) {
    if (_inventory[getTemplateSlot(row)] == null) {
        return false;
    }
    boolean hasIngredients = false;
    for (int i = 0; i < 3; i++) {
        if (UtilInventory.stacksEqual(_inventory[getTemplateSlot(row)], _inventory[getResourceSlot(row, i)])) {
            hasIngredients = true;
            break;
        }
    }
    if (!hasIngredients) {
        return false;
    }
    ItemStack ingredient = _inventory[getTemplateSlot(row)];
    if (!Item.itemsList[ingredient.itemID].isPotionIngredient()) {
        return false;
    }
    if (_inventory[getProcessSlot(row)] != null && _inventory[getProcessSlot(row)].getItem() instanceof ItemPotion) {
        int existingPotion = _inventory[getProcessSlot(row)].getItemDamage();
        int newPotion = this.getPotionResult(existingPotion, ingredient);
        if (!ItemPotion.isSplash(existingPotion) && ItemPotion.isSplash(newPotion)) {
            return true;
        }
        @SuppressWarnings("unchecked") List<Integer> existingEffects = Item.potion.getEffects(existingPotion);
        @SuppressWarnings("unchecked") List<Integer> newEffects = Item.potion.getEffects(newPotion);
        if ((existingPotion <= 0 || existingEffects != newEffects) && (existingEffects == null || !existingEffects.equals(newEffects) && newEffects != null) && existingPotion != newPotion) {
            return true;
        }
    }
    return false;
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemPotion (net.minecraft.item.ItemPotion)11 ItemStack (net.minecraft.item.ItemStack)11 ResourceLocation (net.minecraft.util.ResourceLocation)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 Nullable (javax.annotation.Nullable)2 PotionEffect (net.minecraft.potion.PotionEffect)2 EnumFacing (net.minecraft.util.EnumFacing)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 RecipeQuery (blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery)1 ChemthrowerEffect (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect)1 ChemthrowerEffect_Extinguish (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Extinguish)1 ChemthrowerEffect_Potion (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion)1 DefaultFurnaceAdapter (blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler.DefaultFurnaceAdapter)1 IEFluid (blusunrize.immersiveengineering.common.util.IEFluid)1 AbstractBlockHut (com.minecolonies.coremod.blocks.AbstractBlockHut)1 Permissions (com.minecolonies.coremod.colony.permissions.Permissions)1 ItemScanTool (com.minecolonies.coremod.items.ItemScanTool)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1