IMachine

An IMachine is the actual machine object, you can get it from the IMachineRegistry.

Importing the package

It might be required for you to import the class.
You usually only need to import a class when directly using the name, such as in casting or Array Declarations but better be safe than sorry and add the import.

import extrautilities2.Tweaker.IMachine;

Add Recipes

There are two methods for adding recipes, one uses a probability map for the outputs, one allows for the use of WeightedItemStack and WeightedLiquidStack objects.
Both methods use maps with strings as indices.
These strings will be the names of the input/output slots given, which is why you should not have two slots with the same name in a machine.

Using a probability map

myMachine.addRecipe(inputs, outputs, energy, time, probabilities);

This method uses the following parameters:

名称 Type
inputs IIngredient[string]
outputs IIngredient[string]
energy int
time int
probabilities float[string]

Using only the outputs map

You can also only use the outputs map, then ExtUtils2 will check for any WeightedItemStack and WeightedLiquidStack objects and use their chances.
Remember, that adding anything other than those two or IIngredient as mapped value, will have no effect.

myMachine.addRecipe(inputs, outputs, energy, time);

This method uses the following parameters:

Name Type
inputs IIngredient[string]
outputs Object[string]
energy int
time int

Remove recipes

You can also remove recipes. Again, you use maps with strings as indices.

There are two methods, one uses IIngredient as values, and one that accepts a map with IItemStack and a map with ILiquidStack values.

Using IIngredient

myMachine.removeRecipe(inputs);
Name Type
inputs IIngredient[string]

Using separate maps for Items and Liquids

myMachine.removeRecipe(items, liquids);
Name Type
items IItemStack[string]
liquids ILiquidStack[string]

Retrieving machine information

You can also retrieve some information on the machine using the following methods:

Naming the machine

So far, all our machines will be named machine.crafttweaker:your_machine_name where your_machine_name is whatever name you used to create the machine.

If you want the machine name localized, use either CrT’s IGame capabilities or a custom lang file.

So if your machine name was time_machine, you would need to either call this in a script:

game.setLocalization("machine.crafttweaker:time_machine", "Space Time distorter (Time machine)");

Or add this to a lang file:

machine.crafttweaker:time_machine=Space Time distorter (Time machine)