Skip to content

Commit 0daf785

Browse files
committed
sr: add proper wiki
1 parent 6768947 commit 0daf785

16 files changed

Lines changed: 830 additions & 8 deletions

File tree

wikis/summoningrituals/.vitepress/config.mts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,37 @@ export default defineConfig({
77
themeConfig: {
88
sidebar: [
99
{
10-
text: "Intro",
10+
text: "Introduction",
1111
items: [
12-
{ text: "Introduction", link: "/" },
13-
{ text: "Example", link: "/example" },
12+
{ text: "Getting Started", link: "/" },
13+
{ text: "What's New", link: "/whats_new" },
14+
{ text: "Usage for Players", link: "/usage_for_players" },
15+
{ text: "Usage for Developers", link: "/usage_for_developers" },
16+
{ text: "Full Example", link: "/full_example" },
17+
],
18+
},
19+
{
20+
text: "Recipe",
21+
items: [
22+
{ text: "Basics", link: "/recipe/basics" },
23+
{ text: "Inputs", link: "/recipe/inputs" },
24+
{ text: "Outputs", link: "/recipe/outputs" },
25+
{ text: "Conditions", link: "/recipe/conditions" },
26+
],
27+
},
28+
{
29+
text: "Events",
30+
items: [
31+
{ text: "Event Overview", link: "/event/overview" },
32+
{ text: "Summoning Start", link: "/event/start" },
33+
{ text: "Summoning Complete", link: "/event/complete" },
34+
],
35+
},
36+
{
37+
text: "Bindings",
38+
items: [
39+
{ text: "Summoning Item", link: "/binding/item" },
40+
{ text: "Summoning Entity", link: "/binding/entity" },
1441
],
1542
},
1643
],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summoning Entity
2+
3+
Work in progress!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summoning Item
2+
3+
Work in progress!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summoning Time
2+
3+
Work in progress!
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Summoning Complete Event
2+
3+
This event allows you to invoke logic when a ritual is completed.
4+
5+
**It is a server event and reloadable.** Keep in mind that server events have to be located inside the `kubejs/server_scripts` folder.
6+
7+
## Overview
8+
9+
The event is fired after a ritual has successfully been performed. This means the altar no longer contains the initiator item, the item inputs, and all entity inputs are sacrificed.
10+
11+
At this point, the altar has already invoked the output commands and spawned the item and entity outputs. You can access the spawned outputs within the event.
12+
13+
- access in a server script via: `SummoningRituals.complete`
14+
- properties
15+
- `level`
16+
- type: `ServerLevel`
17+
- description: the level where the ritual completed
18+
- `pos`
19+
- type: `BlockPos`
20+
- description: the position of the altar block
21+
- `recipeInfo`
22+
- type: `RecipeInfoContainer`
23+
- description: a container object holding information about the recipe that was processed
24+
- container properties:
25+
- `recipeId` - the ID of the recipe that was processed as `ResourceLocation`
26+
- `recipe` - the `AltarRecipe` that was processed
27+
- `inputEntities` - an `Entity` collection holding all entities that were sacrificed (already dead)
28+
- `outputItems` - an `ItemEntity` collection holding all item outputs that were spawned
29+
- `outputEntities` - an `Entity` collection holding all entity outputs that were spawned
30+
- `player`
31+
- type: `ServerPlayer` (nullable)
32+
- description: the player who inserted the initiator item; may be null if the ritual was started by automation
33+
34+
## Event Listener
35+
36+
To access the event, the first thing you need to do is to open an event listener for the `complete` event in a server script.
37+
38+
```js
39+
SummoningRituals.complete(event => {
40+
// ...
41+
})
42+
```
43+
44+
## Example
45+
46+
```js
47+
SummoningRituals.complete(event => {
48+
const { level, pos, recipeInfo, player } = event
49+
50+
// check for a specific recipe
51+
if (recipeInfo.recipeId.toString() !== "kubejs:forbidden_ritual") {
52+
return
53+
}
54+
55+
// if an item output is a sword, enchant it with sharpness 3
56+
for (let itemEntity of recipeInfo.outputItems) {
57+
if (itemEntity.item.id.contains("sword")) {
58+
itemEntity.item.enchant("minecraft:sharpness", 3)
59+
}
60+
}
61+
})
62+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Event Overview
2+
3+
| Name | Server | Cancelable |
4+
| --------------------------------- | :----: | :--------: |
5+
| [Summoning Start](start.md) |||
6+
| [Summoning Complete](complete.md) || |
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Summoning Start Event
2+
3+
This event allows you to invoke logic when a ritual is started and to optionally cancel the ritual start.
4+
5+
**It is a server event and reloadable.** Keep in mind that server events have to be located inside the `kubejs/server_scripts` folder.
6+
7+
## Overview
8+
9+
The event is fired after a valid recipe is found but before the ritual is started. This means the altar contains all required item inputs, all required entity inputs are within the sacrifice zone around the altar, and all conditions match.
10+
11+
At this point, the altar block also contains the initiator item and is about to start the ritual.
12+
13+
- access in a server script via: `SummoningRituals.start`
14+
- properties
15+
- `level`
16+
- type: `ServerLevel`
17+
- description: the level where the ritual is about to happen
18+
- `pos`
19+
- type: `BlockPos`
20+
- description: the position of the altar block
21+
- `recipeInfo`
22+
- type: `RecipeInfoContainer`
23+
- description: a container object holding information about the recipe that is about to be processed
24+
- container properties:
25+
- `recipeId` - the ID of the recipe that is about to be processed as `ResourceLocation`
26+
- `recipe` - the `AltarRecipe` that is about to be processed
27+
- `inputEntities` - an `Entity` collection holding all entities that are about to be sacrificed
28+
- `player`
29+
- type: `ServerPlayer` (nullable)
30+
- description: the player who inserted the initiator item; may be null if the ritual was started by automation
31+
- functions
32+
- `cancel()`
33+
- description: cancels the ritual start; this will reset the altar and drop the initiator item
34+
35+
## Event Listener
36+
37+
To access the event, the first thing you need to do is to open an event listener for the `start` event in a server script.
38+
39+
```js
40+
SummoningRituals.start(event => {
41+
// ...
42+
})
43+
```
44+
45+
## Example
46+
47+
```js
48+
SummoningRituals.start(event => {
49+
const { level, pos, recipeInfo, player } = event
50+
51+
// check for a specific recipe
52+
if (recipeInfo.recipeId.toString() !== "kubejs:forbidden_ritual") {
53+
return
54+
}
55+
56+
// cancel the ritual if one of the entity inputs has less than their max health
57+
for (let entity of recipeInfo.inputEntities) {
58+
if (player) {
59+
player.tell("Ritual cancelled: Entity health too low")
60+
}
61+
event.cancel()
62+
}
63+
})
64+
```

wikis/summoningrituals/docs/example.md renamed to wikis/summoningrituals/docs/full_example.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Full Example
2+
3+
This page shows a full example of a very complex altar recipe with all available functions. This example only shows how it looks when you combine the logic described on all other pages. It won't explain any concepts. For that, please read the [usage for developers page](usage_for_developers.md) and navigate from there.
4+
15
```js
26
ServerEvents.recipes(event => {
37
event.recipes.summoningrituals
@@ -25,7 +29,7 @@ ServerEvents.recipes(event => {
2529
SummoningEntity.output("blaze", 2)
2630
.data({
2731
Health: 50,
28-
Attributes: [{ Name: "generic.max_health", Base: 50 }],
32+
attributes: [{ id: "generic.max_health", base: 50 }],
2933
})
3034
.offset([1, 2, 2])
3135
.tooltip([Text.of("50 health").aqua()]),
@@ -45,10 +49,10 @@ ServerEvents.recipes(event => {
4549
.spread([4, 2, 4])
4650
.data({
4751
Health: 50,
48-
Attributes: [{ Name: "generic.max_health", Base: 50 }],
52+
attributes: [{ id: "generic.max_health", base: 50 }],
4953
}),
5054
])
51-
.commands(["say Hi", "/say Hello"]) // doesn't matter if with slash or not
55+
.commands(["say Foo", "/say Bar"])
5256
.sacrificeZone([3, 3, 3])
5357
.conditions(conditions =>
5458
conditions

wikis/summoningrituals/docs/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# Getting Started
22

3-
> [!WARNING]
4-
> This wiki is still work in progress! It just lists all examples for now without further explanation.
3+
> [!WARNING] NOTE
4+
> This wiki is for Summoning Rituals for Minecraft 1.21.1 and above. For previous versions, please refer to the [old wiki](https://github.com/AlmostReliable/summoningrituals/wiki).
5+
6+
Summoning Rituals is intended to be used as a progression mod in modpacks. It adds an Altar block you can use to perform summoning rituals. By default, this mod has no content apart from the block itself.
7+
8+
If you have used the mod in previous versions, you can read the [What's New page](whats_new.md) to see what changed.
9+
10+
For players: Please refer to [this page](/usage_for_players.md).<br>
11+
For developers: Please refer to [this page](/usage_for_developers.md).
12+
13+
If you want to see a full example that uses all available functions, see the [full example page](full_example.md).
514

615
Useful links:
716

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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

Comments
 (0)