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;
}
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;
}
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;
}
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));
}
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));
}
Aggregations