Arqade Asked by Peter Davies-Crandley on May 31, 2021
So i’m currently working on a datapack the reworks the leveling system in Minecraft. One of the things that I’m currently struggling with is putting the xp orb into a scoreboard instead of your xp bar. I have tried multiple different variations of commands but it is not working for some reason.
What I have currently have tried is:
execute as @a at @s unless score @s p_lvl = @s pm_lvl if entity @e[type=experience_orb,nbt={Value:1s},distance=..1.5] run scoreboard players add @s reserve 1
Breaking down the command:
If anyone has any suggestions on how to make this work, that would be great.
For anyone else who is looking for an answer to this question, this is what I came up with and it works quite well.
First, it is recommended that you tag your xp orbs mostly to make the commands look less scary. ex. execute as @e[nbt={Value:1s},tag=] run tag @s add xp.1
You are gonna have to do this for every naturally spawned xp orb [1–11, 17, 37, 73, 149, 307, 617, 1237, 2477].
Next, we need to find the xp orbs in the world that are close to the player, add them to the scoreboard, and (optional) kill them off. Here is my code for doing this:
execute as @a at @s if entity @e[tag=xp.1,distance=..2.5] run scoreboard players add @s xp 1
execute as @a at @s as @e[tag=xp.1,distance=..2.5] run kill @s
This seems to be working 100% (or 99% if your killing them) of the time. Due to Minecraft commands running at 1/20th of a second, there is a very small chance that xp orbs at very close range will make it into your xp bar, without killing itself or being added to the scoreboard.
Answered by Peter Davies-Crandley on May 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP