Skip to content

Commit cda75eb

Browse files
committed
upd: custom component documentation
1 parent 58eb77c commit cda75eb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

content/docs/extension-docs/custom-components.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ interface TemplateContext {
7373
dialogueScene: (sceneDefinition: any, openDialogue = true) => void
7474
onActivated: (eventResponse: any) => void
7575
onDeactivated: (eventResponse: any) => void
76+
lootTable: (lootTable: any) => string
77+
tradeTable: (tradeTable: any) => string
78+
spawnRule: (spawnRule: any) => void
7679
}
7780
```
7881

@@ -97,6 +100,15 @@ interface TemplateContext {
97100
- `dialogueScene(sceneDefinition: any, openDialogue?: boolean): void`
98101
Creates a new dialogue scene to be used within your add-on. This function is only available if your project target version is at least "1.17.40"
99102

103+
- `lootTable(lootTable: any): string`
104+
Returns a string that points to your defined loot table
105+
106+
- `tradeTable(tradeTable: any): string`
107+
Returns a string that points to your defined trade table
108+
109+
- `spawnRule(spawnRule: any): void`
110+
Creates a new spawn rule file for entities that use the custom component
111+
100112
#### Item
101113

102114
```ts
@@ -131,6 +143,8 @@ interface TemplateContext {
131143
condition?: string | false
132144
) => void
133145
}
146+
lootTable: (lootTable: any) => string
147+
recipe: (recipe: any) => void
134148
}
135149
```
136150

@@ -148,6 +162,12 @@ The `player` object gives access to these functions:
148162
- `create(template: any, location?: string): void`
149163
Allows you to create data inside of the player. `template` should be a JavaScript object of the data to merge into the player behavior file at the given `location`. `location` should be a path separated by `'/'` to where you want the `template` to be created. For example: `minecraft:entity/description`. The default merge behaviour can optionally be overridden with `operation` which should be a function that takes default merge function `deepMerge`, the data at `location` (`oldData`) and the new data being merged in (`newData`). It should return the result of the custom merge. For example: `(deepMerge, oldData, newData) => newData` will overwrite the data at `location`.
150164

165+
- `lootTable(lootTable: any): string`
166+
Returns a string that points to your defined loot table
167+
168+
- `recipe(recipe: any): void`
169+
Creates a new recipe for items that use the custom component
170+
151171
#### Block
152172

153173
```ts
@@ -168,6 +188,8 @@ interface TemplateContext {
168188
projectNamespace: string
169189
onActivated: (eventResponse: any) => void
170190
onDeactivated: (eventResponse: any) => void
191+
lootTable: (lootTable: any) => string
192+
recipe: (recipe: any) => void
171193
}
172194
```
173195

@@ -180,6 +202,12 @@ interface TemplateContext {
180202
- `onDeactivated(eventResponse: any): void`
181203
Trigger an event reponse whenever your component gets removed from this block
182204

205+
- `lootTable(lootTable: any): string`
206+
Returns a string that points to your defined loot table
207+
208+
- `recipe(recipe: any): void`
209+
Creates a new recipe for blocks that use the custom component
210+
183211
### Creating Files
184212

185213
Files can also be automatically created with custom components. Functions that can be called to create files are:

0 commit comments

Comments
 (0)