Skip to content

Commit ba76c80

Browse files
committed
sr: document exposed bindings
1 parent 4add53b commit ba76c80

4 files changed

Lines changed: 202 additions & 3 deletions

File tree

wikis/summoningrituals/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default defineConfig({
3838
items: [
3939
{ text: "Summoning Item", link: "/binding/item" },
4040
{ text: "Summoning Entity", link: "/binding/entity" },
41+
{ text: "Summoning Time", link: "/binding/time" },
4142
],
4243
},
4344
],
Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,154 @@
11
# Summoning Entity
22

3-
Work in progress!
3+
`SummoningEntity` is a utility binding that allows you to easily create complex instances of `EntityInput`s and `EntityOutput`s via the `EntityInputBuilder` and `EntityOutputBuilder`. The builders offer functionality to add tooltips, offset and spread values, as well as NBT to entities, which is otherwise not possible, if you only provide a simple [entity input](../recipe/inputs.md#entity-inputs) or [entity output](../recipe/outputs.md#entity-outputs) instance.
4+
5+
## Overview
6+
7+
- access in recipes event via: `SummoningEntity`
8+
- functions:
9+
- `input(EntityInfo entity)`
10+
- creates an `EntityInputBuilder` with the specified `EntityInfo`
11+
- `input(Holder<EntityType<?>> entity, Integer count)`
12+
- creates an `EntityInputBuilder` with the specified entity and the specified count
13+
- `output(EntityInfo entity)`
14+
- creates an `EntityOutputBuilder` with the specified `EntityInfo`
15+
- `output(Holder<EntityType<?>> entity, Integer count)`
16+
- creates an `EntityOutputBuilder` with the specified entity and the specified count
17+
18+
```js
19+
SummoningEntity.input("pig")
20+
SummoningEntity.input("5x minecraft:ghast")
21+
SummoningEntity.input("minecraft:fox", 3)
22+
23+
SummoningEntity.output("cow")
24+
SummoningEntity.output("3x sheep")
25+
SummoningEntity.output("iron_golem", 2)
26+
```
27+
28+
## Entity Input Builder
29+
30+
After obtaining the `EntityInputBuilder` instance through the binding, you can chain more functions to it. It is not required to finish the builder because the `entityInputs` function accepts builder instances as well.
31+
32+
- properties:
33+
- `entity`
34+
- description: specifies the input entity; defined via the binding function to obtain the builder
35+
- type: `Holder<EntityType<?>>`
36+
- required: yes
37+
- `count`
38+
- description: specifies the count of the input entity; defined via the binding function to obtain the builder
39+
- type: `Integer`
40+
- required: no
41+
- default: `1`
42+
- `data`
43+
- description: specifies the data (NBT) of the input entity; only used for rendering
44+
- type: `CompoundTag` (JsonObject)
45+
- required: no
46+
- default: empty
47+
- `tooltip`
48+
- description: specifies additional tooltip lines shown in recipe viewer pages
49+
- type: `List<Component>`
50+
- required: no
51+
- default: empty list
52+
- `validator`
53+
- description: specifies the validator function to check the entity data (NBT)
54+
- type: `Predicate<Entity>`
55+
- required: no
56+
- default: always `true`
57+
- functions:
58+
- `data(CompoundTag data)`
59+
- assigns the given NBT data to the `EntityInput`
60+
- `tooltip(List<Component> tooltip)`
61+
- assigns the given tooltip lines to the `EntityInput`
62+
- `validator(Predicate<Entity> validator)`
63+
- assigns the given validator to the `EntityInput`
64+
65+
> [!TIP] What is a validator?
66+
> You might ask why a custom `validator` is required if `data` is already provided. For inputs, the `data` property is only used for rendering purposes in recipe viewers. If you give an entity a sword via the `data` property, it will be displayed in the recipe viewer page, but it won't be checked if the entity actually has a sword when being sacrificed.
67+
>
68+
> **Why is that?<br>**
69+
> Because vanilla Minecraft only checks entity data (NBT) for exact matches, there is no way to always cover all desired functionality. If you want to ensure that an entity has at least 10 HP, this wouldn't be possible because Minecraft would check for the exact value only. That's why you have to use a custom validator with your own logic to check if the respective values are correct.
70+
71+
```js
72+
.entityInputs([
73+
SummoningEntity.input("cat", 3).tooltip("Meow"), // [!code focus:13]
74+
SummoningEntity.input("zombie")
75+
.data({
76+
HandItems: [
77+
{
78+
id: "minecraft:diamond_sword",
79+
Count: 1,
80+
tag: { ench: [{ id: 16, lvl: 1 }] },
81+
},
82+
],
83+
})
84+
.tooltip("Needs any sword")
85+
.validator((e) => e.mainHandItem.id.contains("sword")),
86+
])
87+
```
88+
89+
## Entity Output Builder
90+
91+
After obtaining the `EntityOutputBuilder` instance through the binding, you can chain more functions to it. It is not required to finish the builder because the `entityOutputs` function accepts builder instances as well.
92+
93+
- properties:
94+
- `entity`
95+
- description: specifies the output entity; defined via the binding function to obtain the builder
96+
- type: `Holder<EntityType<?>>`
97+
- required: yes
98+
- `count`
99+
- description: specifies the count of the output entity; defined via the binding function to obtain the builder
100+
- type: `Integer`
101+
- required: no
102+
- default: `1`
103+
- `data`
104+
- description: specifies the data (NBT) of the output entity
105+
- type: `CompoundTag` (JsonObject)
106+
- required: no
107+
- default: empty
108+
- `tooltip`
109+
- description: specifies additional tooltip lines shown in recipe viewer pages
110+
- type: `List<Component>`
111+
- required: no
112+
- default: empty list
113+
- `offset`
114+
- description: specifies the offset to the altar block where to spawn the output entity at
115+
- type: `BlockPos`
116+
- required: no
117+
- default: `[0, 2, 0]`
118+
- `spread`
119+
- description: specifies the spread of the output entities; output entities are spawned at different positions within the spread area; a single entity can spawn at a position before a new random position is calculated
120+
- type: `BlockPos`
121+
- required: no
122+
- default: `[1, 0, 1]`
123+
- functions:
124+
- `data(CompoundTag data)`
125+
- assigns the given NBT data to the `EntityOutput`
126+
- `tooltip(List<Component> tooltip)`
127+
- assigns the given tooltip lines to the `EntityOutput`
128+
- `offset(BlockPos offset)`
129+
- assigns the given offset to the `EntityOutput`
130+
- `spread(BlockPos spread)`
131+
- assigns the given spread to the `EntityOutput`
132+
133+
```js
134+
.entityOutputs([
135+
SummoningEntity.output("5x creeper").tooltip("Kaboom"), // [!code focus:18]
136+
SummoningEntity.output("skeleton", 2)
137+
.data({
138+
HandItems: [
139+
{
140+
id: "minecraft:diamond_sword",
141+
Count: 1,
142+
tag: { ench: [{ id: 16, lvl: 1 }] },
143+
},
144+
],
145+
}),
146+
SummoningEntity.output("6x sheep")
147+
.offset([1, 2, 2])
148+
.spread([4, 2, 4])
149+
.data({
150+
Health: 50,
151+
attributes: [{ id: "generic.max_health", base: 50 }],
152+
}),
153+
])
154+
```
Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
11
# Summoning Item
22

3-
Work in progress!
3+
`SummoningItem` is a utility binding that allows you to easily create complex instances of `ItemOutput`s via the `ItemOutputBuilder`. The builder offers functionality to add offset and spread values to an item output, which is otherwise not possible, if you only provide a simple [item output](../recipe/outputs.md#item-outputs) instance.
4+
5+
## Overview
6+
7+
- access in recipes event via: `SummoningItem`
8+
- functions:
9+
- `of(ItemStack result)`
10+
- creates an `ItemOutputBuilder` with the specified item and its assigned count
11+
- `of(ItemStack result, int count)`
12+
- creates an `ItemOutputBuilder` with the specified item and the specified count
13+
14+
```js
15+
SummoningItem.of("iron_ingot")
16+
SummoningItem.of("5x minecraft:apple")
17+
SummoningItem.of(Item.of("potato", 3))
18+
SummoningItem.of("minecraft:carrot", 2)
19+
```
20+
21+
## Item Output Builder
22+
23+
After obtaining the `ItemOutputBuilder` instance through the binding, you can chain more functions to it. It is not required to finish the builder because the `itemOutputs` function accepts builder instances as well.
24+
25+
- properties:
26+
- `item`
27+
- description: specifies the output item; defined via the binding function to obtain the builder
28+
- type: `ItemStack`
29+
- required: yes
30+
- `offset`
31+
- description: specifies the offset to the altar block where to spawn the output item at
32+
- type: `BlockPos`
33+
- required: no
34+
- default: `[0, 2, 0]`
35+
- `spread`
36+
- description: specifies the spread of the output items; output items are spawned at different positions within the spread area; 4 items can spawn at a position before a new random position is calculated
37+
- type: `BlockPos`
38+
- required: no
39+
- default: `[1, 0, 1]`
40+
- functions:
41+
- `offset(BlockPos offset)`
42+
- assigns the given offset to the `ItemOutput`
43+
- `spread(BlockPos spread)`
44+
- assigns the given spread to the `ItemOutput`
45+
46+
```js
47+
.itemOutputs([
48+
SummoningItem.of("emerald", 16).offset([1, 2, 2]).spread([4, 2, 4]) // [!code focus]
49+
])
50+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Summoning Time
22

3-
Work in progress!
3+
This binding is exposed for use in the [time condition](../recipe/conditions.md#time). Please refer to that section to read more about it.

0 commit comments

Comments
 (0)