[1.17] 随机数生成 | 战利品表引用记分板
这个数据包是如此的简单,以至于它很适合用来在 MCBBS 上灌水(

下载:
- 初始化
代码:
- # 建立记分板
- scoreboard objectives add random dummy
- # 设置最小值
- scoreboard players set #min random 233
- # 设置最大值
- scoreboard players set #max random 666
- 战利品表:引用了记分板上的最大值和最小值
代码:
- {
- "pools": [
- {
- "rolls": 1,
- "entries": [
- {
- "type": "minecraft:item",
- "name": "minecraft:stone",
- "functions": [
- {
- "function": "minecraft:set_nbt",
- "tag": "{randomMarker:1b}"
- },
- {
- "function": "minecraft:set_attributes",
- "modifiers": [
- {
- "attribute": "minecraft:generic.luck",
- "name": "random_luck",
- "amount": {
- "type": "minecraft:uniform",
- "min": {
- "type": "minecraft:score",
- "target": {
- "type": "minecraft:fixed",
- "name": "#min"
- },
- "score": "random"
- },
- "max": {
- "type": "minecraft:score",
- "target": {
- "type": "minecraft:fixed",
- "name": "#max"
- },
- "score": "random"
- }
- },
- "operation": "addition",
- "slot": "mainhand"
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- }
- 随机数生成:除反馈外,只有三条命令
代码:
- # 生成掉落物
- loot spawn ~ -65 ~ loot random:random
- # 获取随机数
- 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
- # 移除掉落物
- execute positioned ~ -65 ~ run kill @e[type=minecraft:item,nbt={Item:{tag:{randomMarker:1b}}},distance=..1]
- # 反馈给玩家
- tellraw @s ["",{"text":"随机数的结果是: "},{"score":{"objective":"random","name":"#result"}}]
见识到了,楼主真有你的
牛批啊,楼主
运用到1.17什么性质了?
,可以啊,这操作np
Xiao2 发表于 2021-1-9 16:44
运用到1.17什么性质了?
运用到1.17什么性质了?
现在战利品表里的数字可以引用记分板分数了。
例如,以下战利品表,掉落 1 颗石头。
代码:
- {
- "pools": [
- {
- "rolls": 1,
- "entries": [
- {
- "type": "minecraft:item",
- "name": "minecraft:stone",
- "functions": [
- {
- "function": "minecraft:set_count",
- "count": 1
- }
- ]
- }
- ]
- }
- ]
- }
以下战利品表,掉落石头的数量由玩家 ljyys 的 hahaha 记分板的分数动态控制。
代码:
- {
- "pools": [
- {
- "rolls": 1,
- "entries": [
- {
- "type": "minecraft:item",
- "name": "minecraft:stone",
- "functions": [
- {
- "function": "minecraft:set_count",
- "count": {
- "type": "minecraft:score",
- "target": {
- "type": "minecraft:fixed",
- "name": "ljyys"
- },
- "score": "hahaha"
- }
- }
- ]
- }
- ]
- }
- ]
- }