Search in sources :

Example 1 with ZenMethod

use of stanhebben.zenscript.annotations.ZenMethod in project SilentGems by SilentChaos512.

the class CTSilentGems method setToolRecipe.

@ZenMethod
public static void setToolRecipe(String itemClass, int tierRestriction, String[] recipe, Object... ingredients) {
    Item toolItem = Item.getByNameOrId(SilentGems.RESOURCE_PREFIX + itemClass.toLowerCase());
    EnumMaterialTier tier = null;
    if (tierRestriction >= 0 && tierRestriction < EnumMaterialTier.values().length) {
        tier = EnumMaterialTier.values()[tierRestriction];
    }
    Object[] params = new Object[recipe.length + ingredients.length];
    for (int i = 0; i < recipe.length; ++i) {
        params[i] = recipe[i];
    }
    for (int i = 0; i < ingredients.length; ++i) {
        if (ingredients[i] instanceof String) {
            String str = (String) ingredients[i];
            if (str.length() == 1) {
                // Character?
                params[recipe.length + i] = str.charAt(0);
            } else if (str.startsWith("ore:")) {
                // Oredict key?
                params[recipe.length + i] = str.replaceFirst("ore:", "");
            } else {
                // Item string?
                // We can't use CraftTweaker's typical ingredient annotation (<mod:item_name:meta>) because it doesn't yield
                // any values I can use. :(
                String[] array = str.split(":");
                String itemName = array[0] + ":" + array[1];
                Item item = Item.getByNameOrId(itemName);
                if (item != null) {
                    int meta = 0;
                    if (array.length > 2) {
                        try {
                            meta = Integer.parseInt(array[2]);
                        } catch (NumberFormatException ex) {
                        // Ignore
                        }
                    }
                    params[recipe.length + i] = new ItemStack(item, 1, meta);
                }
            }
        } else {
            // Nothing else will work, I assume? But pass it along anyway.
            params[recipe.length + i] = ingredients[i];
        }
    }
    ActionAddMixedMaterialRecipe action = new ActionAddMixedMaterialRecipe(toolItem, tier, params);
    MCRecipeManager.recipesToAdd.add(action);
// RECIPES_TO_ADD.add(action);
}
Also used : Item(net.minecraft.item.Item) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemStack(net.minecraft.item.ItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with ZenMethod

use of stanhebben.zenscript.annotations.ZenMethod in project Charset by CharsetMC.

the class MaterialRegistry method registerRelation.

@ZenMethod
public static boolean registerRelation(IItemStack from, String what, IItemStack to) {
    ItemStack mcStackFrom = CraftTweakerMC.getItemStack(from);
    ItemStack mcStackTo = CraftTweakerMC.getItemStack(to);
    if (mcStackFrom.isEmpty() || mcStackTo.isEmpty()) {
        return false;
    }
    CraftTweakerAPI.apply(new IAction() {

        @Override
        public void apply() {
            ItemMaterialRegistry.INSTANCE.registerRelation(ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(mcStackFrom), ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(mcStackTo), what);
        }

        @Override
        public String describe() {
            return "Registering material relation (" + from + " --[" + what + "]-> " + to + ")";
        }
    });
    return true;
}
Also used : IAction(crafttweaker.IAction) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 3 with ZenMethod

use of stanhebben.zenscript.annotations.ZenMethod in project TechReborn by TechReborn.

the class CTAssemblingMachine method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
    Object oInput1 = CraftTweakerCompat.toObject(input1);
    Object oInput2 = CraftTweakerCompat.toObject(input2);
    AssemblingMachineRecipe r = new AssemblingMachineRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output), ticktime, euTick);
    addRecipe(r);
}
Also used : AssemblingMachineRecipe(techreborn.api.recipe.machines.AssemblingMachineRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 4 with ZenMethod

use of stanhebben.zenscript.annotations.ZenMethod in project TechReborn by TechReborn.

the class CTBlastFurnace method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IIngredient input1, IIngredient input2, int ticktime, int euTick, int neededHeat) {
    Object oInput1 = CraftTweakerCompat.toObject(input1);
    Object oInput2 = CraftTweakerCompat.toObject(input2);
    BlastFurnaceRecipe r = new BlastFurnaceRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), ticktime, euTick, neededHeat);
    addRecipe(r);
}
Also used : BlastFurnaceRecipe(techreborn.api.recipe.machines.BlastFurnaceRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 5 with ZenMethod

use of stanhebben.zenscript.annotations.ZenMethod in project TechReborn by TechReborn.

the class CTCentrifuge method addRecipe.

@ZenMethod
public static void addRecipe(IItemStack output1, IItemStack output2, IItemStack output3, IItemStack output4, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
    Object oInput1 = CraftTweakerCompat.toObject(input1);
    Object oInput2 = CraftTweakerCompat.toObject(input2);
    CentrifugeRecipe r = new CentrifugeRecipe(oInput1, oInput2, CraftTweakerCompat.toStack(output1), CraftTweakerCompat.toStack(output2), CraftTweakerCompat.toStack(output3), CraftTweakerCompat.toStack(output4), ticktime, euTick);
    addRecipe(r);
}
Also used : CentrifugeRecipe(techreborn.api.recipe.machines.CentrifugeRecipe) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

ZenMethod (stanhebben.zenscript.annotations.ZenMethod)67 ItemStack (net.minecraft.item.ItemStack)23 IItemStack (crafttweaker.api.item.IItemStack)14 FluidStack (net.minecraftforge.fluids.FluidStack)7 PharmacologyEffect (minechem.potion.PharmacologyEffect)6 IItemStack (minetweaker.api.item.IItemStack)6 PotionChemical (minechem.potion.PotionChemical)4 NetRecipe (betterwithaddons.crafting.recipes.NetRecipe)3 CherryBoxRecipe (betterwithaddons.crafting.recipes.CherryBoxRecipe)2 GristSet (com.mraof.minestuck.util.GristSet)2 IAction (crafttweaker.IAction)2 ChemicalRoomStateEnum (minechem.item.ChemicalRoomStateEnum)2 PackingRecipe (betterwithaddons.crafting.recipes.PackingRecipe)1 SmeltingRecipe (betterwithaddons.crafting.recipes.SmeltingRecipe)1 SpindleRecipe (betterwithaddons.crafting.recipes.SpindleRecipe)1 WoodHardness (betterwithaddons.handler.StumpingHandler.WoodHardness)1 ItemMaterial (betterwithaddons.item.ItemMaterial)1 TreeFood (betterwithaddons.tileentity.TileEntityLureTree.TreeFood)1 IngredientCraftTweaker (betterwithaddons.util.IngredientCraftTweaker)1 BrewedGrainRecipe (binnie.extratrees.machines.brewery.recipes.BrewedGrainRecipe)1