Say there is a player called Dave with a Health score of 10 and a MaxHealth score of 20. I need to check if there is any players with a health score lower than MaxHealth and tellraw it. Also is there a way to add values onto Health say 60 or 20 but without it going over MaxHealth? E.G. Health + 60 = MaxHealth (without going over)? Thanks in advance.
Minecraft – Testing if there is an entity with a objective score lower than another objective score
minecraft-commandsminecraft-java-edition
Related Topic
- Minecraft – How to get /testfor to only find one player with a score value
- Minecraft Java Edition – How to Create a Variable in Minecraft
- minecraft-java-edition – How to Access Another Player’s Inventory on a LAN World
- minecraft-java-edition – How to Check If a Scoreboard Objective Is Not Greater Than a Certain Integer in Minecraft Command Blocks
- Minecraft 1.12 reliably detect player-player interaction
- Minecraft – Is the alpha channel supported in Minecraft tellraw
Best Answer
How can I tellraw all players with less than full health:
You can use
to modify a players score by the value of another score(even between players).
But unfortunately, I couldn't find an objective criteria for MAX_HEALTH. (might be worth a feature request on bugs.mojang.com)
If there should be one, you would need 3 objectives to do what you want:
You need a clock to run all of these following commands:
For the tellraw, use the selector tag in the json text:
How can I heal players without going over maxHealth:
You can't modify a health scoreboard value. Instead use the
command to heal players. The amount of health added is equal to
duration * 2 ^ amplifier
See Potion effects (ID 6)
Edit according to comment:
(All objectives = dummy) You can use the operation command again to achieve this: Just add an arbitrary value to your score and then execute this:
This will limit the "Health" score of every player to his "MaxHealth" score