乐桃兔酪乳 发表于 2024-2-24 00:14:06

「指令」[1.13.2+]如何使用Bossbar实时显示生物血量 - 教程中心 - Minecraf

<br /><br /><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px">&nbsp; &nbsp;&nbsp; &nbsp; 在日常的电子斗蛐蛐中,经常有一些生物没有血条导致观感不好,我偶然发现服务器的TPSbar便查找到boss栏的指令bossbar,因为是个指令小白老是忘相当于把本帖当个备忘录</font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;思路就是先创建bossbar 然后生成一个生物或选择一个生物,获取生命值,然后存放到这个bossbar里,最后循环以实时更新</font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /><img onerror="study_killerrpic(this)" id="aimg_RrwNQ" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://klpbbs.com/static/image/hrline/line2.png" onmouseover="img_onmouseoverfunc(this)" lazyloadthumb="1" border="0" alt="" /><br /><br /></font></font></font><font style="color:rgb(0, 0, 0)"><strong><font face="宋体"><font size="5">第一步 创建bossbar</font></font></strong></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li> /bossbar add id {&quot;text&quot;:&quot;name&quot;} </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">id自己取一个,name同理</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">然后根据对应生物设置bossbar最大值(如凋灵300就写300)</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li> /bossbar set id max 0 </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">改数字即可</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">随后对玩家显示</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li> /bossbar set id players @a </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">补充,如果想要不同样式的bossbar可以这样调整:</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">⑴分段:</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li> /bossbar set id style notched_6 </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">改数字即可</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">⑵颜色:</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li>/bossbar set id color white </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">仅支持白蓝绿粉紫红黄</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">⑶显示与否:</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><ol><li>/bossbar set id visible true </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">true显示,false隐藏</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">⑷修改名称:同创建指令,只需修改name</font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /><img onerror="study_killerrpic(this)" id="aimg_zc8tC" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://klpbbs.com/static/image/hrline/4.gif" onmouseover="img_onmouseoverfunc(this)" lazyloadthumb="1" border="0" alt="" /><br /><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font face="宋体"><font size="5"><strong>第二步 获取生物血量</strong></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">因为data get似乎不能直接选择@e(至少我这是这样,难道要加上limit=1?){补充,确实是这样}</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">所以先给生物一个tag这样选择器就能选中它了</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">如果是原有的生物用<ol><li> /tag @e add text </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">修改mob和text即可,下同(如凋灵tag为wither就是:</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">/tag @e add wither)</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">如果生成可以用<ol><li>/summon mob ~ ~ ~ {Tags:[&quot;text&quot;]}</ol></font></font></font><font face="仿宋, 仿宋_GB2312"><br /></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">然后获取血量<ol><li>/data get entity @e Health </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312">这时把data指令放到循环命令方块里后应该就可以实时输出生物血量了</font></font></font><font style="color:rgb(0, 0, 0)"><font style="font-size:17px"><font face="仿宋, 仿宋_GB2312"><br /></font></font></font><font face="仿宋, 仿宋_GB2312">后来补充:经实践,@e可行</font><font face="仿宋, 仿宋_GB2312">故可以直接如下:</font><ol><li>/data get entity @e Health</ol><font face="仿宋, 仿宋_GB2312"><br /></font><font face="仿宋, 仿宋_GB2312">缺点在于只会选取最近类型的该生物,bossbar可能会被篡位。比如你选择最近一个僵尸,僵尸走远了又刷新一个,这时候就显示新僵尸的血量了</font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /><img onerror="study_killerrpic(this)" id="aimg_I2R1q" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://klpbbs.com/static/image/hrline/line4.png" onmouseover="img_onmouseoverfunc(this)" lazyloadthumb="1" border="0" alt="" /><br /><br /></font></font></font><font style="color:rgb(0, 0, 0)"><strong><font face="宋体"><font size="5">第三步 实时更新血量到bossbar</font></font></strong></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px">前两部我们完成了bossbar的创建及血量获取,现在只需要把在生物血量变化时更新bossbar,为了同时运行这两个指令我们可以使用execute…run…,前半部分将data get获取的生命值储存到bossbar里更新bossbar,后半部分就是data get health</font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px">整合后如下:</font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><ol><li> /execute store result bossbar minecraft:id value run data get entity @e Health </ol></font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px"><br /></font></font></font><font style="color:rgb(0, 0, 0)"><font face="仿宋, 仿宋_GB2312"><font style="font-size:17px">扔到循环命令方块后就可以使用啦!</font></font></font><font face="仿宋, 仿宋_GB2312"><br /><br /></font><br /><br>来源:<a href="https://klpbbs.com/thread-131091-1-1.html" target="_blank">https://klpbbs.com/thread-131091-1-1.html</a><br>免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

暗月寺代柔 发表于 2024-3-7 21:39:22

再来波拓展,如果想要在生物在时显示bossbar并且死亡时隐藏bossbar,可以参考如下代码(应该有更简单的)<br /><br />两种思路(当然推荐第二种,但是第一种可以作别的用途):<br /><br />1.跟踪生物血量,如果大于0显示,如果等于0隐藏<br />显示:<ol><li>/execute as @e unless entity @s run bossbar set id visible true</ol><br />隐藏(但是实测用不了):<ol><li>/execute as @e if entity @s run bossbar set id visible false</ol><br /><br />2.检测周围是否有该实体:<br />显示:<ol><li>/execute if entity @e run bossbar set id visible true</ol><br />隐藏:<ol><li>/execute unless entity @e run bossbar set id visible false</ol>

娅静小仙女 发表于 2024-5-29 21:25:51

gbbybbbgbubibg g
页: [1]
查看完整版本: 「指令」[1.13.2+]如何使用Bossbar实时显示生物血量 - 教程中心 - Minecraf