Search in sources :

Example 1 with IOreDictEntry

use of minetweaker.api.oredict.IOreDictEntry in project Minechem by iopleke.

the class InputHelper method getChemical.

public static PotionChemical getChemical(IIngredient ingredient) {
    if (ingredient instanceof IngredientStack) {
        for (IIngredient in : ingredient.getItems()) {
            if (in instanceof IItemStack) {
                ItemStack result = toStack((IItemStack) in);
                result.stackSize = Math.max(1, ingredient.getAmount());
                PotionChemical chemical = MinechemUtil.itemStackToChemical(result);
                if (chemical != null) {
                    return chemical;
                }
            }
        }
        return null;
    } else if (ingredient instanceof IOreDictEntry) {
        ArrayList<ItemStack> results = (ArrayList<ItemStack>) OreDictionary.getOres(((IOreDictEntry) ingredient).getName()).clone();
        for (ItemStack res : results) {
            ItemStack result = res.copy();
            result.stackSize = ingredient.getAmount();
            PotionChemical chemical = MinechemUtil.itemStackToChemical(result);
            if (chemical != null) {
                return chemical;
            }
        }
    } else if (ingredient instanceof IItemStack) {
        return MinechemUtil.itemStackToChemical(toStack((IItemStack) ingredient));
    }
    return null;
}
Also used : IIngredient(minetweaker.api.item.IIngredient) IItemStack(minetweaker.api.item.IItemStack) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry) ArrayList(java.util.ArrayList) PotionChemical(minechem.potion.PotionChemical) IngredientStack(minetweaker.api.item.IngredientStack) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IOreDictEntry

use of minetweaker.api.oredict.IOreDictEntry in project Minechem by iopleke.

the class InputHelper method getItem.

public static ItemStack getItem(IIngredient input) {
    if (input == null) {
        return null;
    }
    if (input instanceof IOreDictEntry) {
        ItemStack result = OreDictionary.getOres(((IOreDictEntry) input).getName()).get(0).copy();
        result.stackSize = input.getAmount();
        if (MinechemUtil.itemStackToChemical(result) != null) {
            return null;
        }
        return result;
    } else if (input instanceof IngredientStack) {
        ItemStack result = toStack(input.getItems().get(0));
        result.stackSize = input.getAmount();
        if (MinechemUtil.itemStackToChemical(result) != null) {
            return null;
        }
        return result;
    } else if (input instanceof IItemStack) {
        if (MinechemUtil.itemStackToChemical(toStack((IItemStack) input)) != null) {
            return null;
        }
        return toStack((IItemStack) input);
    }
    return null;
}
Also used : IItemStack(minetweaker.api.item.IItemStack) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) IngredientStack(minetweaker.api.item.IngredientStack)

Example 3 with IOreDictEntry

use of minetweaker.api.oredict.IOreDictEntry in project Minechem by iopleke.

the class InputHelper method getInputs.

public static ArrayList<ItemStack> getInputs(IIngredient input) {
    ArrayList<ItemStack> toAdd = new ArrayList<ItemStack>();
    if (input instanceof IOreDictEntry) {
        for (ItemStack inStack : OreDictionary.getOres(((IOreDictEntry) input).getName())) {
            ItemStack result = inStack.copy();
            result.stackSize = input.getAmount();
            toAdd.add(result);
        }
    } else if (input instanceof IItemStack) {
        toAdd.add(InputHelper.toStack((IItemStack) input));
    }
    return toAdd;
}
Also used : IItemStack(minetweaker.api.item.IItemStack) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry) ArrayList(java.util.ArrayList) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IOreDictEntry

use of minetweaker.api.oredict.IOreDictEntry in project Minechem by iopleke.

the class InputHelper method getInput.

public static ItemStack getInput(IIngredient input) {
    if (input == null) {
        return null;
    }
    if (input instanceof IOreDictEntry) {
        ItemStack result = OreDictionary.getOres(((IOreDictEntry) input).getName()).get(0).copy();
        result.stackSize = input.getAmount();
        return result;
    } else if (input instanceof IngredientStack) {
        ItemStack result = toStack(input.getItems().get(0));
        result.stackSize = input.getAmount();
        return result;
    } else if (input instanceof IItemStack) {
        return toStack((IItemStack) input);
    }
    return null;
}
Also used : IItemStack(minetweaker.api.item.IItemStack) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry) IItemStack(minetweaker.api.item.IItemStack) ItemStack(net.minecraft.item.ItemStack) IngredientStack(minetweaker.api.item.IngredientStack)

Example 5 with IOreDictEntry

use of minetweaker.api.oredict.IOreDictEntry in project CraftTweaker by CraftTweaker.

the class OreBracketHandler method getOreList.

public static List<IOreDictEntry> getOreList(String wildcardName) {
    List<IOreDictEntry> result = new ArrayList<>();
    Pattern wildcardPattern = Pattern.compile(wildcardName.replaceAll("\\*", ".+"));
    for (IOreDictEntry someOreDict : MineTweakerAPI.oreDict.getEntries()) {
        String oreDictName = someOreDict.getName();
        if (wildcardPattern.matcher(oreDictName).matches()) {
            result.add(getOre(oreDictName));
        }
    }
    return result;
}
Also used : Pattern(java.util.regex.Pattern) IOreDictEntry(minetweaker.api.oredict.IOreDictEntry)

Aggregations

IOreDictEntry (minetweaker.api.oredict.IOreDictEntry)6 IItemStack (minetweaker.api.item.IItemStack)4 ItemStack (net.minecraft.item.ItemStack)4 IngredientStack (minetweaker.api.item.IngredientStack)3 ArrayList (java.util.ArrayList)2 Pattern (java.util.regex.Pattern)2 PotionChemical (minechem.potion.PotionChemical)1 IIngredient (minetweaker.api.item.IIngredient)1