(=°ω°)丿


[1.17] 随机数生成 | 战利品表引用记分板


这个数据包是如此的简单,以至于它很适合用来在 MCBBS 上灌水(


下载:





代码:

  1. # 建立记分板
  2. scoreboard objectives add random dummy
  3. # 设置最小值
  4. scoreboard players set #min random 233
  5. # 设置最大值
  6. scoreboard players set #max random 666


代码:

  1. {
  2. "pools": [
  3.     {
  4.    "rolls": 1,
  5.    "entries": [
  6.   {
  7.     "type": "minecraft:item",
  8.     "name": "minecraft:stone",
  9.     "functions": [
  10.    {
  11.   "function": "minecraft:set_nbt",
  12.   "tag": "{randomMarker:1b}"
  13.    },
  14.    {
  15.   "function": "minecraft:set_attributes",
  16.   "modifiers": [
  17.     {
  18.    "attribute": "minecraft:generic.luck",
  19.    "name": "random_luck",
  20.    "amount": {
  21.   "type": "minecraft:uniform",
  22.   "min": {
  23.     "type": "minecraft:score",
  24.     "target": {
  25.    "type": "minecraft:fixed",
  26.    "name": "#min"
  27.     },
  28.     "score": "random"
  29.   },
  30.   "max": {
  31.     "type": "minecraft:score",
  32.     "target": {
  33.    "type": "minecraft:fixed",
  34.    "name": "#max"
  35.     },
  36.     "score": "random"
  37.   }
  38.    },
  39.    "operation": "addition",
  40.    "slot": "mainhand"
  41.     }
  42.   ]
  43.    }
  44.     ]
  45.   }
  46.    ]
  47.     }
  48. ]
  49. }


代码:

  1. # 生成掉落物
  2. loot spawn ~ -65 ~ loot random:random
  3. # 获取随机数
  4. execute positioned ~ -65 ~ store result score #result random run data get entity @e[type=minecraft:item,nbt={Item:{tag:{randomMarker:1b}}},limit=1,distance=..1] Item.tag.AttributeModifiers[0].Amount 1
  5. # 移除掉落物
  6. execute positioned ~ -65 ~ run kill @e[type=minecraft:item,nbt={Item:{tag:{randomMarker:1b}}},distance=..1]
  7. # 反馈给玩家
  8. tellraw @s ["",{"text":"随机数的结果是: "},{"score":{"objective":"random","name":"#result"}}]



神奇的火焰
见识到了,楼主真有你的

鲸落毁生
牛批啊,楼主

Xiao2
运用到1.17什么性质了?

起名是真的难啊
,可以啊,这操作np

(=°ω°)丿
Xiao2 发表于 2021-1-9 16:44
运用到1.17什么性质了?

现在战利品表里的数字可以引用记分板分数了。
例如,以下战利品表,掉落 1 颗石头。

代码:

  1. {
  2. "pools": [
  3.     {
  4.    "rolls": 1,
  5.    "entries": [
  6.   {
  7.     "type": "minecraft:item",
  8.     "name": "minecraft:stone",
  9.     "functions": [
  10.    {
  11.   "function": "minecraft:set_count",
  12.   "count": 1
  13.    }
  14.     ]
  15.   }
  16.    ]
  17.     }
  18. ]
  19. }

以下战利品表,掉落石头的数量由玩家 ljyys 的 hahaha 记分板的分数动态控制。

代码:

  1. {
  2. "pools": [
  3.     {
  4.    "rolls": 1,
  5.    "entries": [
  6.   {
  7.     "type": "minecraft:item",
  8.     "name": "minecraft:stone",
  9.     "functions": [
  10.    {
  11.   "function": "minecraft:set_count",
  12.   "count": {
  13.     "type": "minecraft:score",
  14.     "target": {
  15.    "type": "minecraft:fixed",
  16.    "name": "ljyys"
  17.     },
  18.     "score": "hahaha"
  19.   }
  20.    }
  21.     ]
  22.   }
  23.    ]
  24.     }
  25. ]
  26. }

第一页 上一页 下一页 最后一页