Skip to content

Commit 2566bb3

Browse files
committed
lootjs: update to match LootJS 3.6.0
1 parent de0163d commit 2566bb3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

wikis/lootjs/docs/api/item-filter.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,20 @@ ItemFilter.hasStoredEnchantment(["minecraft:fortune", "minecraft:mending"])
142142
ItemFilter.hasStoredEnchantment("minecraft:unbreaking", [2, 3])
143143
```
144144

145+
## `hasComponent`
146+
147+
Used to check if given item has specific components on it.
148+
149+
- Syntax:
150+
- `ItemFilter.hasComponent(filter)`
151+
152+
```js
153+
ItemFilter.hasComponent("minecraft:tool")
154+
155+
// check against multiple components. Requires the item to have all of the components
156+
ItemFilter.hasComponent("minecraft:tool", "minecraft:custom_name")
157+
```
158+
145159
## `item`
146160

147161
Matches if the item matches. This will not check for count but may check against components.

wikis/lootjs/docs/api/loot-modifier.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Replaces all `items` which matches the given [ItemFilter] with a replacement. It
142142
- Syntax:
143143
- `.replaceLoot(item: string | Item | LootEntry, replacement: string | Item | LootEntry)`, _<sub>see [LootEntry]</sub>_
144144
- `.replaceLoot(item: string | Item | LootEntry, replacement: string | Item | LootEntry, preserveCount?: boolean)`
145+
- `.replaceLoot(item: string | Item | LootEntry, replacement: string | Item | LootEntry, preserveCount?: boolean, preserveComponentTypes?: string[])`
145146

146147
```js
147148
LootJS.modifiers(event => {
@@ -159,6 +160,16 @@ LootJS.modifiers(event => {
159160
})
160161
```
161162

163+
We also can preserve specific component types by passing the ids as an array.
164+
165+
```js
166+
LootJS.modifiers(event => {
167+
event
168+
.addTableModifier(LootType.CHEST)
169+
.replaceLoot(ItemFilter.ENCHANTED, "minecraft:stick", true, ["minecraft:enchantments"])
170+
})
171+
```
172+
162173
## `modifyLoot`
163174

164175
For every `item` in the current loot pool which matches the given [ItemFilter], a callback will be called. `LootJS` will pass the item into the callback to modify it and return the `item`. Make sure to always return an `item`!

0 commit comments

Comments
 (0)