Search in sources :

Example 1 with IItemStack

use of crafttweaker.api.item.IItemStack 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 2 with IItemStack

use of crafttweaker.api.item.IItemStack in project artisan-worktables by codetaylor.

the class CTArtisanRecipe method processRecipeFunction.

@ParametersAreNonnullByDefault
private IArtisanItemStack processRecipeFunction(IRecipeFunction recipeFunction, IArtisanItemStack output, ICraftingContext context) {
    Map<String, IItemStack> marks = new HashMap<>();
    if (this.isShaped()) {
        marks = this.getMarksShaped(context, marks);
    } else {
        marks = this.getMarksShapeless(context, marks);
    }
    try {
        IItemStack functionResult = recipeFunction.process(((CTArtisanItemStack) output).getIItemStack(), marks, this.getCraftingInfo(context));
        output = ArtisanItemStack.from(CraftTweakerMC.getItemStack(functionResult));
    } catch (Throwable e) {
        CraftTweakerAPI.logError("Error executing RecipeFunction", e);
    }
    return output;
}
Also used : HashMap(java.util.HashMap) IItemStack(crafttweaker.api.item.IItemStack) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 3 with IItemStack

use of crafttweaker.api.item.IItemStack in project artisan-worktables by codetaylor.

the class CTArtisanRecipe method getRemainingItems.

@Nonnull
@Override
protected List<ItemStack> getRemainingItems(ICraftingContext context, NonNullList<ItemStack> itemStacks) {
    MatchInfo matchInfo;
    if (this.isShaped()) {
        matchInfo = this.getStacksShaped(context);
    } else {
        matchInfo = this.getStacksShapeless(context);
    }
    ICraftingMatrixStackHandler matrixHandler = context.getCraftingMatrixHandler();
    List<IArtisanIngredient> ingredients = this.getIngredientList();
    IItemStack[] stacks = matchInfo.getStacks();
    int[] matrixIndices = matchInfo.getMatrixIndices();
    for (int i = 0; i < ingredients.size(); i++) {
        IArtisanIngredient artisanIngredient = ingredients.get(i);
        if (artisanIngredient.isEmpty()) {
            continue;
        }
        if (artisanIngredient instanceof CTArtisanIngredient) {
            IIngredient ingredient = ((CTArtisanIngredient) artisanIngredient).getIngredient();
            if (ingredient.hasNewTransformers()) {
                IItemStack remainingItem = null;
                try {
                    remainingItem = ingredient.applyNewTransform(stacks[i]);
                } catch (Throwable e) {
                    CraftTweakerAPI.logError("Could not execute NewRecipeTransformer on " + ingredient.toCommandString(), e);
                }
                itemStacks.set(matrixIndices[i], CraftTweakerMC.getItemStack(remainingItem));
            }
        } else {
            itemStacks.set(matrixIndices[i], Util.getContainerItem(matrixHandler.getStackInSlot(matrixIndices[i])));
        }
    }
    return itemStacks;
}
Also used : IIngredient(crafttweaker.api.item.IIngredient) IItemStack(crafttweaker.api.item.IItemStack) Nonnull(javax.annotation.Nonnull)

Example 4 with IItemStack

use of crafttweaker.api.item.IItemStack in project Minestuck by mraof.

the class Alchemy method removeCost.

@ZenMethod
public static void removeCost(IItemStack iStack) {
    ItemStack stack = (ItemStack) iStack.getInternal();
    recipes.add(new SetCost(stack.getItem(), stack.getItemDamage(), null));
}
Also used : ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 5 with IItemStack

use of crafttweaker.api.item.IItemStack in project Minestuck by mraof.

the class Alchemy method setCost.

@ZenMethod
public static void setCost(IItemStack iStack, String cost) {
    ItemStack stack = (ItemStack) iStack.getInternal();
    GristSet grist = getGrist(cost);
    if (grist == null)
        return;
    recipes.add(new SetCost(stack.getItem(), stack.getItemDamage(), grist));
}
Also used : GristSet(com.mraof.minestuck.util.GristSet) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

IItemStack (crafttweaker.api.item.IItemStack)24 ItemStack (net.minecraft.item.ItemStack)18 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)14 IIngredient (crafttweaker.api.item.IIngredient)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 IAction (crafttweaker.IAction)2 IngredientStack (crafttweaker.api.item.IngredientStack)2 CraftTweakerMC (crafttweaker.api.minecraft.CraftTweakerMC)2 IOreDictEntry (crafttweaker.api.oredict.IOreDictEntry)2 PackingRecipe (betterwithaddons.crafting.recipes.PackingRecipe)1 IngredientCraftTweaker (betterwithaddons.util.IngredientCraftTweaker)1 BrewedGrainRecipe (binnie.extratrees.machines.brewery.recipes.BrewedGrainRecipe)1 BreweryRecipe (binnie.extratrees.machines.brewery.recipes.BreweryRecipe)1 FruitPressRecipe (binnie.extratrees.machines.fruitpress.recipes.FruitPressRecipe)1 LumbermillRecipe (binnie.extratrees.machines.lumbermill.recipes.LumbermillRecipe)1 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)1 MetalPressRecipe (blusunrize.immersiveengineering.api.crafting.MetalPressRecipe)1 GristSet (com.mraof.minestuck.util.GristSet)1 IMod (crafttweaker.api.mods.IMod)1 BracketHandlerItem (crafttweaker.mc1120.brackets.BracketHandlerItem)1