Skip to content

Commit de0163d

Browse files
committed
lootjs: remove deprecated entry and some fixes
1 parent 22d7491 commit de0163d

File tree

4 files changed

+34
-41
lines changed

4 files changed

+34
-41
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ May return `null`, depending on the type of the loot table.
4343

4444
```js
4545
LootJS.modifiers(event => {
46-
event.addTypeModifier("chest").customAction((context, loot) => {
46+
event.addTableModifier(LootType.CHEST).customAction((context, loot) => {
4747
console.log(context.entity)
4848
})
4949
})
@@ -59,7 +59,7 @@ May return `null`, depending on the type of the loot table.
5959

6060
```js
6161
LootJS.modifiers(event => {
62-
event.addTypeModifier("entity").customAction((context, loot) => {
62+
event.addTableModifier(LootType.ENTITY).customAction((context, loot) => {
6363
console.log(context.attackingEntity)
6464
})
6565
})
@@ -75,7 +75,7 @@ May return `null`, depending on the type of the loot table.
7575

7676
```js
7777
LootJS.modifiers(event => {
78-
event.addTypeModifier("entity").customAction((context, loot) => {
78+
event..addTableModifier(LootType.ENTITY).customAction((context, loot) => {
7979
console.log(context.damageSource)
8080
})
8181
})
@@ -89,7 +89,7 @@ LootJS.modifiers(event => {
8989

9090
```js
9191
LootJS.modifiers(event => {
92-
event.addTypeModifier("block").customAction((context, loot) => {
92+
event..addTableModifier(LootType.BLOCK).customAction((context, loot) => {
9393
console.log(context.tool)
9494
})
9595
})

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ LootEntry.of("minecraft:diamond")
6868
LootEntry.of("minecraft:diamond", [5, 10])
6969
```
7070

71-
```js
72-
const entry = LootEntry.of("minecraft:diamond_sword")
73-
74-
if (entry.test(ItemFilter.SWORD)) {
75-
// do something
76-
}
77-
```
78-
7971
### EmptyEntry
8072

8173
- Syntax:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ For every `item` in the current loot pool which matches the given [ItemFilter],
168168

169169
```js
170170
LootJS.modifiers(event => {
171-
event.addTypeModifier("chest").modifyLoot(ItemFilter.ENCHANTED, item => {
171+
event.addTableModifier(LootType.CHEST).modifyLoot(ItemFilter.ENCHANTED, item => {
172172
// We will remove the enchantments component from the item
173173
// So un-enchant it.
174174
item.remove("minecraft:enchantments")
@@ -186,7 +186,7 @@ Triggers a lightning strike at the position the loot is dropped at. The `items`
186186

187187
```js
188188
LootJS.modifiers(event => {
189-
event.addTypeModifier("chest").triggerLightningStrike(false)
189+
event.addTableModifier(LootType.CHEST).triggerLightningStrike(false)
190190
})
191191
```
192192

@@ -199,7 +199,7 @@ Drops an `amount` of experience on the position where the loot will be dropped.
199199

200200
```js
201201
LootJS.modifiers(event => {
202-
event.addTypeModifier("chest").triggerLightningStrike(false)
202+
event.addTableModifier(LootType.CHEST).triggerLightningStrike(false)
203203
})
204204
```
205205

@@ -243,7 +243,7 @@ Adds a custom action to the loot modifier. The action gives you access to the [L
243243

244244
```js
245245
LootJS.modifiers(event => {
246-
event.addTypeModifier("chest").customAction((context, loot) => {
246+
event.addTableModifier(LootType.CHEST).customAction((context, loot) => {
247247
if (loot.hasItem("#c:ores")) {
248248
loot.addItem("minecraft:gunpowder")
249249
}

wikis/lootjs/docs/loot-modifiers/event.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,29 @@ Remove all global loot modifiers from mods by given filter.
2121
Add a new loot modifier for all loot tables which match the given filter.
2222

2323
- Syntax:
24-
- `.addTableModifier(filter: string | string[] | regex)`, returns a [LootModifier]
24+
- `.addTableModifier(filter: LootTableFilter | LootTableFilter[])`, returns a [LootModifier]
25+
26+
A `LootTableFilter` can be a string, regex, or a `LootType`.
27+
28+
```ts
29+
enum LootType {
30+
CHEST,
31+
BLOCK,
32+
ENTITY,
33+
EQUIPMENT,
34+
FISHING,
35+
ARCHAEOLOGY,
36+
GIFT,
37+
VAULT,
38+
SHEARING,
39+
PIGLIN_BARTER,
40+
}
41+
```
2542

2643
```js
2744
LootJS.modifiers(event => {
2845
event
2946
.addTableModifier("minecraft:chests/simple_dungeon")
30-
.randomChance(0.5)
3147
.addLoot("minecraft:gunpowder")
3248
})
3349
```
@@ -37,29 +53,16 @@ LootJS.modifiers(event => {
3753
// Or we can also use a regex
3854
event
3955
.addTableModifier(/minecraft:chests:.*/)
40-
.randomChance(0.5)
4156
.addLoot("minecraft:gunpowder")
4257
})
4358
```
4459

45-
## `addTypeModifier`
46-
47-
Add a new loot modifier for given loot types.
48-
Valid loot types are `chest`, `block`, `entity`, `fishing`, `archaeology`, `gift`, `vault`, `shearing`, `piglin_barter`
49-
50-
- Syntax:
51-
- `.addTypeModifier(type: LootType)`, returns a [LootModifier]
52-
5360
```js
5461
LootJS.modifiers(event => {
55-
event.addTypeModifier("chest").randomChance(0.5).addLoot("minecraft:gunpowder")
56-
})
57-
```
58-
59-
```js
60-
LootJS.modifiers(event => {
61-
// We can also use multiple ones
62-
event.addTypeModifier("block", "entity").randomChance(0.5).addLoot("minecraft:gunpowder")
62+
// Or we can also use a regex
63+
event
64+
.addTableModifier(LootType.CHEST)
65+
.addLoot("minecraft:gunpowder")
6366
})
6467
```
6568

@@ -72,22 +75,21 @@ Add a new loot modifier for all entities which match the given filter.
7275

7376
```js
7477
LootJS.modifiers(event => {
75-
event.addEntityModifier("minecraft:creeper").randomChance(0.5).addLoot("minecraft:gunpowder")
78+
event.addEntityModifier("minecraft:creeper").addLoot("minecraft:gunpowder")
7679
})
7780
```
7881

7982
```js
8083
LootJS.modifiers(event => {
8184
event
8285
.addEntityModifier(["minecraft:cow", "minecraft:pig"])
83-
.randomChance(0.5)
8486
.addLoot("minecraft:gold_nugget")
8587
})
8688
```
8789

8890
```js
8991
LootJS.modifiers(event => {
90-
event.addEntityModifier("#minecraft:skeletons").randomChance(0.5).addLoot("minecraft:stick")
92+
event.addEntityModifier("#minecraft:skeletons").addLoot("minecraft:stick")
9193
})
9294
```
9395

@@ -100,22 +102,21 @@ Add a new loot modifier for all blocks which match the given filter.
100102

101103
```js
102104
LootJS.modifiers(event => {
103-
event.addBlockModifier("minecraft:iron_ore").randomChance(0.5).addLoot("minecraft:iron_nugget")
105+
event.addBlockModifier("minecraft:iron_ore").addLoot("minecraft:iron_nugget")
104106
})
105107
```
106108

107109
```js
108110
LootJS.modifiers(event => {
109111
event
110112
.addBlockModifier(["minecraft:gravel", "minecraft:dirt"])
111-
.randomChance(0.5)
112113
.addLoot("minecraft:gold_nugget")
113114
})
114115
```
115116

116117
```js
117118
LootJS.modifiers(event => {
118-
event.addBlockModifier("#c:ores").randomChance(0.5).addLoot("minecraft:flint")
119+
event.addBlockModifier("#c:ores").addLoot("minecraft:flint")
119120
})
120121
```
121122

0 commit comments

Comments
 (0)