|
| 1 | +# Recipe Basics |
| 2 | + |
| 3 | +Summoning Rituals provides a single crafting recipe type that is reused across all systems: the altar recipe. |
| 4 | + |
| 5 | +It is possible to create custom recipes via datapacks as well, but it's not recommended since you'd miss a lot of customization options. Instead, you should make use of [KubeJS](https://github.com/KubeJS-Mods/KubeJS) because the mod has native integration for it. |
| 6 | + |
| 7 | +> [!WARNING] NOTE |
| 8 | +> Due to the limitations, creating the recipe via datapacks is not documented on this wiki. |
| 9 | +
|
| 10 | +## Creating a Recipe |
| 11 | + |
| 12 | +To create a new altar recipe, you need to set up a listener for the recipe event in a KubeJS server script. Keep in mind that server events have to be located inside the `kubejs/server_scripts` folder. |
| 13 | + |
| 14 | +```js |
| 15 | +ServerEvents.recipes(event => { |
| 16 | + event.recipes.summoningrituals.altar("minecraft:stick") |
| 17 | +}) |
| 18 | +``` |
| 19 | + |
| 20 | +The `altar()` function creates a new instance of the altar recipe builder. It takes a single argument, which acts as the **initiator** of the recipe. An initiator must be inserted last into the altar to start the recipe after all other inputs have been placed. For this, you can use any kind of `Ingredient`. That means it allows a simple item or a tag. |
| 21 | + |
| 22 | +> [!TIP] NOTE |
| 23 | +> Specifying a count will not have any effect because an initiator can only be a single item. |
| 24 | +
|
| 25 | +After calling the function, you can chain many different functions to assign inputs, outputs, and conditions. You can read more about that in the following sections. |
| 26 | + |
| 27 | +## Recipe Components |
| 28 | + |
| 29 | +Each recipe uses the same set of components which define inputs, outputs, conditions, and special information like custom tooltips. |
| 30 | + |
| 31 | +### Structure |
| 32 | + |
| 33 | +- `initiator` |
| 34 | + - type: `Ingredient` |
| 35 | + - required: yes (passed to `.altar(...)`) |
| 36 | + - description: the item used to start the ritual |
| 37 | +- `item_inputs` |
| 38 | + - type: `List<SizedIngredient>` |
| 39 | + - required: no |
| 40 | + - default: empty list |
| 41 | + - primary access: `itemInputs(...)` |
| 42 | + - aliases: `itemInput`, `inputs`, `input` |
| 43 | + - description: items consumed when the ritual starts |
| 44 | +- `entity_inputs` |
| 45 | + - type: `List<EntityInput>` |
| 46 | + - required: no |
| 47 | + - default: empty list |
| 48 | + - primary access: `entityInputs(...)` |
| 49 | + - aliases: `entityInput`, `mobInputs`, `mobInput` |
| 50 | + - description: entities inside the sacrifice zone that are killed when the ritual starts |
| 51 | +- `item_outputs` |
| 52 | + - type: `List<ItemOutput>` |
| 53 | + - required: no |
| 54 | + - default: empty list |
| 55 | + - primary access: `itemOutputs(...)` |
| 56 | + - aliases: `itemOutput`, `outputs`, `output` |
| 57 | + - description: items spawned around the altar when the ritual finishes |
| 58 | +- `entity_outputs` |
| 59 | + - type: `List<EntityOutput>` |
| 60 | + - required: no |
| 61 | + - default: empty list |
| 62 | + - primary access: `entityOutputs(...)` |
| 63 | + - aliases: `entityOutput`, `mobOutputs`, `mobOutput` |
| 64 | + - description: entities spawned around the altar when the ritual finishes |
| 65 | +- `commands` |
| 66 | + - type: `CommandOutput` |
| 67 | + - required: no |
| 68 | + - default: empty |
| 69 | + - primary access: `commands(...)` |
| 70 | + - aliases: `command` |
| 71 | + - description: commands executed when the ritual completes |
| 72 | +- `zone` |
| 73 | + - type: `BlockPos` |
| 74 | + - required: no |
| 75 | + - default: `[3, 2, 3]` |
| 76 | + - primary access: `entityInputZone(...)` |
| 77 | + - aliases: `entityInputZone`, `mobInputZone`, `inputZone`, `sacrificeZone`, `entityZone`, `mobZone`, `zone` |
| 78 | + - description: half-size region around altar used to search required entities |
| 79 | +- `conditions` |
| 80 | + - type: `List<LootItemCondition>` |
| 81 | + - required: no |
| 82 | + - default: empty list |
| 83 | + - primary access: `conditions(...)` |
| 84 | + - description: conditions evaluated before the ritual can start |
| 85 | +- `ticks` |
| 86 | + - type: `int` |
| 87 | + - required: no |
| 88 | + - default: `40` |
| 89 | + - primary access: `ticks(...)` |
| 90 | + - aliases: `time`, `duration` |
| 91 | + - description: ritual duration in game ticks |
| 92 | + |
| 93 | +### Inputs |
| 94 | + |
| 95 | +Inputs can be items, entities, or both. If you want to learn more about how players interact with the altar to provide the required inputs, check out the [player usage page](../usage_for_players.md). |
| 96 | + |
| 97 | +Item inputs support components. That means an input item could specify a required enchantment. Item input components are strictly enforced in the recipe. That means if the item does not have the specified component, the input will not be valid for the recipe. |
| 98 | + |
| 99 | +Entity inputs support data (known as NBT). Contrary to item inputs, this data is not enforced. It is only being used for rendering purposes in the recipe viewer pages. If specific NBT should be enforced, you have to attach a custom validator to the entity input. Entity inputs are considered a sacrifice when they are within the sacrifice zone. |
| 100 | + |
| 101 | +For more information about inputs with all available functions and examples, please read the [inputs page](inputs.md). |
| 102 | + |
| 103 | +### Outputs |
| 104 | + |
| 105 | +Outputs can be items, entities, commands, or all three. |
| 106 | + |
| 107 | +Similar to inputs, outputs support components as well. Items with components and entities with NBT will be spawned with their assigned data. Additionally, item and entity outputs can have custom spawn positions altered by offset and spread values. |
| 108 | + |
| 109 | +Furthermore, commands can be used as outputs. When the ritual finishes, the altar will invoke these commands on the server. You can specify whether a command requires player interaction. Commands with required player context won't be invoked if the ritual was performed by automation. |
| 110 | + |
| 111 | +For more information about outputs with all available functions and examples, please read the [outputs page](outputs.md). |
| 112 | + |
| 113 | +### Conditions |
| 114 | + |
| 115 | +This component defines which conditions need to be fulfilled before the ritual can start. Conditions are additive meaning if multiple conditions are specified, they all have to pass. |
| 116 | + |
| 117 | +The condition system hijacks the vanilla Minecraft loot condition system. Plenty of conditions that can be used for loot can also be used for rituals. |
| 118 | + |
| 119 | +To learn more about available conditions and how to specify them, please read the [conditions page](conditions.md). |
| 120 | + |
| 121 | +### Ticks |
| 122 | + |
| 123 | +The `ticks` component defines the duration the ritual needs to be finished. When the ritual starts, all item inputs are consumed and all entity inputs are killed (they don't drop any loot). An animation will play while the ritual is active. When it's done, the altar will spawn the item and entity outputs and invoke the output commands. |
| 124 | + |
| 125 | +Values passed to this function are specified in ticks (_1 second = 20 ticks_). Higher values mean longer duration for the ritual. |
| 126 | + |
| 127 | +## Recipe Validation |
| 128 | + |
| 129 | +After a recipe has been created, the mod will check its validity internally. There are multiple checks in place to ensure a recipe is valid. |
| 130 | + |
| 131 | +1. the initiator **cannot** be empty |
| 132 | + - this happens if an invalid item id was specified or if the tag provided does not exist |
| 133 | +2. the recipe **must** have at least one item or entity input |
| 134 | +3. the amount of inputs exceeds the specified altar inventory size in the config |
| 135 | + - you can set the size higher in the config |
| 136 | + - this restriction exists to prevent the altar from being used as an infinite storage solution |
| 137 | +4. the recipe **must** have at least one item, entity, or command output |
| 138 | + |
| 139 | +In addition to the general validation, a recipe performs the following steps before it can start: |
| 140 | + |
| 141 | +1. initiator item matches |
| 142 | +2. all item inputs are present in altar inventory |
| 143 | +3. all entity inputs are found inside the configured zone |
| 144 | +4. all start conditions pass |
| 145 | +5. start event is not blocked |
| 146 | + |
| 147 | +After the duration ticks have elapsed, the ritual executes commands, and spawns outputs. |
0 commit comments