Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
M1hono committed Sep 17, 2024
2 parents 2fdca78 + ef2b5ec commit 7fd70c6
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 12 deletions.
1 change: 0 additions & 1 deletion docs/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {

Expand Down
113 changes: 113 additions & 0 deletions docs/zh/modpack/kubejs/1.20.1/Introduction/LootTable/Block.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,117 @@ ServerEvents.blockLootTables(event => {

## 战利品谓词

### 随机概率

- 通过小数表示的随机概率。

- 语句:randomChance(数字);

- 例:

::: code-group

```js [应用战利品池]
// 有0.5的概率尝试抽取该池 此时概率决定是否尝试抽取战利品池
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder');
pool.randomChance(0.5);
})
})
})
```

```js [应用战利品项]
// 有0.5的概率尝试掉落火药 此时概率决定抽取战利品池后是否掉落火药
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder').randomChance(0.5);
})
})
})
```

:::

### 未被爆炸破坏

- 返回成功概率为1 / 爆炸半径,如果上下文未传递爆炸则始终通过。

- 语句:survivesExplosion()

- 示例:如果燧石被爆炸摧毁不会掉落火药。

```js
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder').survivesExplosion()
})
})
})
```

## 战利品修饰

### 对战利品项随机附魔

- 将对战利品项从附魔列表中随机附魔。

- 语句:enchantRandomly(附魔id数组);

- 示例:掉落了保护1的金苹果。

```js
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.enchantRandomly(['minecraft:protection'])
})
})
})
```

### 对战利品项按等级附魔

- 对战利品项执行一次数字提供器返回的等级的附魔。

- 语句:enchantWithLevels(数字提供器, 是否包含宝藏附魔);

- 示例:砂砾掉落一把30级附魔的铁剑。

```js
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.addItem(Item.of('minecraft:iron_sword', '{Damage:0}'), 5, 1)
.enchantWithLevels(30, true)
})
})
})
```

### 熔炉熔炼

- 得到物品放入熔炉冶炼后的产物。

- 语句:furnaceSmelt()

- 示例:砂砾掉落橡木的熔炉冶炼产物。

```js
ServerEvents.blockLootTables(event => {
event.modifyBlock('minecraft:gravel', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:oak_wood', 5, 1).furnaceSmelt()

})
})
})
```
96 changes: 95 additions & 1 deletion docs/zh/modpack/kubejs/1.20.1/Introduction/LootTable/Chest.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

```js
ServerEvents.chestLootTables(event=>{
event.addChest("minecraft:end_city_treasure",loot=>{
event.addChest('minecraft:end_city_treasure', loot=>{
loot.addPool(pool=>{
pool.rolls = [1, 1];
pool.addItem('minecraft:golden_apple');
Expand Down Expand Up @@ -48,4 +48,98 @@ ServerEvents.chestLootTables(event=>{

## 战利品谓词

### 随机概率

- 通过小数表示的随机概率。

- 语句:randomChance(数字);

- 例:

::: code-group

```js [应用战利品池]
// 有0.5的概率尝试抽取该池 此时概率决定是否尝试抽取战利品池
ServerEvents.chestLootTables(event => {
event.modify('minecraft:end_city_treasure', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder');
pool.randomChance(0.5);
})
})
})
```

```js [应用战利品项]
// 有0.5的概率尝试掉落火药 此时概率决定抽取战利品池后是否掉落火药
ServerEvents.chestLootTables(event => {
event.modify('minecraft:end_city_treasure', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder').randomChance(0.5);
})
})
})
```

:::

## 战利品修饰

### 对战利品项随机附魔

- 将对战利品项从附魔列表中随机附魔。

- 语句:enchantRandomly(附魔id数组);

- 示例:掉落了保护1的金苹果。

```js
ServerEvents.chestLootTables(event => {
event.modify('minecraft:end_city_treasure', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.enchantRandomly(['minecraft:protection'])
})
})
})
```

### 对战利品项按等级附魔

- 对战利品项执行一次数字提供器返回的等级的附魔。

- 语句:.enchantWithLevels(数字提供器, 是否包含宝藏附魔);

- 示例:尸壳掉落一把30级附魔的铁剑。

```js
ServerEvents.chestLootTables(event => {
event.modify('minecraft:end_city_treasure', loot => {
loot.addPool(pool => {
pool.addItem(Item.of('minecraft:iron_sword', '{Damage:0}'), 5, 1)
.enchantWithLevels(30, true)
})
})
})
```

### 熔炉熔炼

- 得到物品放入熔炉冶炼后的产物。

- 语句:furnaceSmelt()

- 示例:尸壳死亡掉落橡木的熔炉冶炼产物。

```js
ServerEvents.chestLootTables(event => {
event.modify('minecraft:end_city_treasure', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:oak_wood', 5, 1).furnaceSmelt()

})
})
})
```
151 changes: 150 additions & 1 deletion docs/zh/modpack/kubejs/1.20.1/Introduction/LootTable/Entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

- 语句:event.addEntity(方块id, loot => { loot.addPool(pool => { }) });

- 示例:砂砾只会掉落火药
- 示例:尸壳只会掉落火药

::: code-group

Expand Down Expand Up @@ -134,4 +134,153 @@ ServerEvents.entityLootTables(event => {

## 战利品谓词

### 随机概率

- 通过小数表示的随机概率。

- 语句:randomChance(数字);

- 例:

::: code-group

```js [应用战利品池]
// 有0.5的概率尝试抽取该池 此时概率决定是否尝试抽取战利品池
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder');
pool.randomChance(0.5);
})
})
})
```

```js [应用战利品项]
// 有0.5的概率尝试掉落火药 此时概率决定抽取战利品池后是否掉落火药
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.rolls = [1, 1];
pool.addItem('minecraft:gunpowder').randomChance(0.5);
})
})
})
```

:::

### 抢夺影响概率

- 根据抢夺附魔等级影响条件通过的概率。

- 语句:randomChanceWithLooting(无抢夺的基础概率,每级抢夺增加的概率);

- 示例:尸壳有0.2概率掉落金苹果,每1级抢夺多0.2概率。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.randomChanceWithLooting(0.2, 0.2)
})
})
})
```

### 被玩家所击杀

- 实体死于被玩家击杀则条件通过。

- 语句:killedByPlayer();

- 示例:尸壳死于玩家掉落金苹果。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.killedByPlayer()
})
})
})
```

## 战利品修饰

### 对战利品项随机附魔

- 将对战利品项从附魔列表中随机附魔。

- 语句:enchantRandomly(附魔id数组);

- 示例:掉落了保护1的金苹果。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.enchantRandomly(['minecraft:protection'])
})
})
})
```

### 对战利品项按等级附魔

- 对战利品项执行一次数字提供器返回的等级的附魔。

- 语句:.enchantWithLevels(数字提供器, 是否包含宝藏附魔);

- 示例:尸壳掉落一把30级附魔的铁剑。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem(Item.of('minecraft:iron_sword', '{Damage:0}'), 5, 1)
.enchantWithLevels(30, true)
})
})
})
```

### 抢夺额外掉落

- 语句:lootingEnchant(每级抢夺掉落数-数字提供器, 战利品项总计最大掉落数);

- 示例:尸壳掉落金苹果,每多1级抢夺额外掉落1-2个,总共最多掉落6个。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:golden_apple', 5, 1)
.lootingEnchant([1, 2], 6)
})
})
})
```

### 熔炉熔炼

- 得到物品放入熔炉冶炼后的产物。

- 语句:furnaceSmelt()

- 示例:尸壳死亡掉落橡木的熔炉冶炼产物。

```js
ServerEvents.entityLootTables(event => {
event.modifyEntity('minecraft:husk', loot => {
loot.addPool(pool => {
pool.addItem('minecraft:oak_wood', 5, 1).furnaceSmelt()

})
})
})
```
Loading

0 comments on commit 7fd70c6

Please sign in to comment.