Cold-Pot
MC有简易的取随机数的方法吗
不用循环、保持开启的那种
我只需要1~10就行了 谢谢!!!

JJ怪大战
不要命令方块的只能取1-9

JJ怪大战
或者用另外一种办法?应该也可以

xmdhs
https://www.mcbbs.net/thread-706030-1-1.html

Cold-Pot
JJ怪大战 发表于 2020-3-3 15:34
不要命令方块的只能取1-9

那么1~9怎么取(脉冲和连锁式可以的)

mczsf
https://www.mcbbs.net/thread-912912-1-1.html
这里我问过了,你参考里面的

///////////////////
其实可以用随机传送来实现...

水母山楂
可以用spreadplayers命令来随机,在一个3*3的平面里(上方不可以有方块遮挡)放置压力板和命令方块, 然后用spreadplayers命令把一个实体随机放在3*3的平面里的某个位置, 接触到压力板然后就让命令方块执行命令。
摘自 随机分数

brooke_zb
随机数不多的话就用这个方法也行:召唤10个药水云储存10个标签,对应1到10
  1. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand1"]}
  2. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand2"]}
  3. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand3"]}
  4. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand4"]}
  5. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand5"]}
  6. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand6"]}
  7. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand7"]}
  8. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand8"]}
  9. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand9"]}
  10. summon area_effect_cloud ~ ~ ~ {Duration:2147483647,WaitTime:-2147483648,Age:-2147483648,Tags:["rand","rand10"]}
复制代码
让后取随机
  1. execute as @e[tag=rand,limit=1,sort=random] run function 判定函数
复制代码
判定函数如下
  1. execute if entity @s[tag=rand1] run 对应指令
  2. execute if entity @s[tag=rand2] run 对应指令
  3. execute if entity @s[tag=rand3] run 对应指令
  4. execute if entity @s[tag=rand4] run 对应指令
  5. execute if entity @s[tag=rand5] run 对应指令
  6. execute if entity @s[tag=rand6] run 对应指令
  7. execute if entity @s[tag=rand7] run 对应指令
  8. execute if entity @s[tag=rand8] run 对应指令
  9. execute if entity @s[tag=rand9] run 对应指令
  10. execute if entity @s[tag=rand10] run 对应指令
复制代码
简单暴力

JJ怪大战
用投掷器可以取1-9的随机数

Piglin_42313
JJ怪大战 发表于 2020-3-3 16:12
用投掷器可以取1-9的随机数

发射器+漏斗可以取几乎无限

Cold-Pot
42313123123123 发表于 2020-3-3 16:23
发射器+漏斗可以取几乎无限

但是我是mcfunction做的(起床战争纯指令版本),我不可能setblock完再撸掉把……

Cold-Pot
xmdhs 发表于 2020-3-3 15:38
https://www.mcbbs.net/thread-706030-1-1.html

你的方法很好 但是我复制或者引用这个数据包可能会造成卡顿(其实就是看不懂的借口)