Skip to content
whizzball1 edited this page Dec 19, 2018 · 1 revision

Adding methods is... slightly complicated. Let's go method by method in ManaInfusionMethod, ShapelessTwoByTwoMethod, and FourWaySymmetricalShapedThreeByThreeMethod.

Step 1: getRequiredItems(). I didn't make this code nor did I change it at all. In fact, it might be completely useless and I'm probably going to remove it. But bear with it for now. In the crafting methods it follows from AbstractCraftingMethod.


Step 2: writeZenscript(). This one probably takes the most creativity to implement.

  • For Mana Infusion, I use Heck.random (which is a Random object) to get a number between 3000 and 10000 for mana cost. Then I use String.format() to input all the information. stackToBracket conveniently produces a string version of whatever item you give it. It can be found in AbstractHeckMethod.
    • If you want multiple items out of a recipe then just add more %ss and use random again. Something like %s * %s where the first is the bracketed stack and the second is the number of outputs.
  • For 2x2 Shapeless, Quat used stacksToBracketedList, which can also be found in AbstractHeckMethod.
  • 3x3 symmetrical is by far the most creative, and also totally Quat's idea. Look at it in wonder.

Step 3: removeExistingRecipe(). This one may take a check. Basically, every time the mod adds a recipe, I run a command called removeRecipe() in AbstractHeckMethod that iterates through all the modules and runs all of their removeExistingRecipe() commands. That means there are zero nada no recipes for the item I'm making a recipe for, not from any mods that I've made modules for. But some mods' CraftTweaker remove commands spam the console if the removal fails.

  • Like for Mana Infusion. Only make the check if you actually can--look at the CraftTweaker or ModTweaker implementation to see if there is one.
  • The crafting ones are in AbstractCraftingMethod.

Step 4: getRequiredImports() uses the Optional parameter. return Optional.empty() if there are no imports and Optional.of("import string") if there are. Don't forget your semi-colons!


Step 5: Constructor method. Just run super(inputcount).


Step 6: Sanity variable. There are three types of sanitySets you may need: one of Heck.GoodItemStacks, one of HashSet<ShapelessStack>s, and one of List<Heck.GoodItemStack>s. These are thoroughly tested (probably).

  • Remember that Sets are Lists that only allow for one of each item.
  • Mana Infusion uses a set of items. GoodItemStacks care only about the inner item and the metadata, not count.
  • 2x2 shapeless uses a Set of HashSets of ShapelessStacks.
    • ShapelessStacks contain a GoodItemStack and the number of times that item appears in the recipe.
    • Using ShapelessStacks requires an additional method, ShapelessAdd. It's hard for me to explain this bit. You'll have to figure it out from the code for now.
  • 3x3 shaped uses a Set of Lists of GoodItemStacks. Much easier to use than my shapeless implementation.

Step 7: chooseInputs() and sanityCheck(). The former outputs a pair because I need to know if I just can't add any more rcecipes to it. Then my mod will switch away from it and pick some other recipe method.

  • It should always loop through input choice and sanity check until it succeeds at making a recipe that hasn't already been made.
  • If you've done your implementation well, sanityCheck() should be very simple.
  • The meat of the item choice occurs in Heck.chooseItem(). You do not need to think about this one very hard—the mod will handle the whole choice with all of the extra parameters with ease. Your goal is simply to ensure that no duplicate recipes ever happen.
  • In Mana Infusion, this is accomplished by getting the chosen item and running it through the sanityCheck.
  • In 2x2, this is accomplished by running shapelessAdd() on all the items in recipeStacks. Its particular implementation ensures that the recipe is uniquely identified.
  • In 3x3, since order matters, I simply iterate through recipeStacks and add every item to a sanityList.
  • Make sure to add the final form of your sanity list to the sanitySet outside of your loop.
  • Your return value should say "false" if you've sanity-checked too many times and nothing has worked. Mana Infusion and Smelting are the only methods that actually do this; all the crafting methods simply return true, assuming that there will never be such a horrible failure.

Step 8: Add the method to your module or to HeckMethods by adding a variable for the method class and initialising the variable + registering the method in init().

Clone this wiki locally