Context

Get some context about the current crafting process

Context is the object provided in the function requirement using the Crafttweaker integration.

It contains various methods for interacting with the machine.

Methods

chevron-rightSet the result of the functionhashtag

Every function MUST return a result, which is either a success or an error.

//Get a success result
ctx.success();

//Get an error result
ctx.error("Some error message");
chevron-rightGet the remaining crafting timehashtag

Name : remainingTime

Description :

Return a decimal value that represent the time in ticks before the end of the current recipe process. This value does not take into account any speed modifiers applied to the machine.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

.requireFunctionEachTick((ctx as Context) => {
		var time = ctx.remainingTime;
                //Use time here
	})
chevron-rightGet the crafting process base speedhashtag

Name : baseSpeed

Description :

Return a decimal value that represent the base speed (before upgrades are applied) of the crafting process.

By default it returns 1

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

.requireFunctionEachTick((ctx as Context) => {
		var baseSpeed = ctx.baseSpeed;
                //Use baseSpeed here
	})
chevron-rightSet the crafting process base speedhashtag

Name : baseSpeed

Description :

Set a decimal value as the base speed (before upgrades are applied) of the crafting process.

The new speed must not be negative.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example :

.requireFunctionOnStart((ctx as Context) => {
		ctx.baseSpeed = 2;
	})
chevron-rightGet the crafting process modified speedhashtag

Name : modifiedSpeed

Description :

Return a decimal value that represent the modified speed (after upgrades are applied) of the crafting process.

Note : This method won't work when used inside requireFunctionToStart, the other 3 function requirements are fine to use.

Example

chevron-rightGet the machine as a tile entityhashtag

Name : tile

Description :

Return a BlockEntityarrow-up-right, you can use it to get various information about the machine, see the linked CT wiki page.

Example

chevron-rightGet the machine as a custom machinehashtag

Name : machine

Description :

Return a Machine, you can use it to check, input and output energy, fluids and items from/to the machine.

Example

Last updated