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