I have a little question, because I'm working on a map right now and need a command to heal each time as much life as you harm a mob / player. I play in the 1.14.1 on the PC in a vanilla Minecraft world.
I thank you in advance
Uff, that's hard. This is not possible with a single command.
First of all, you have to find out which player has beaten which player (with creatures that does not). You need two scoreboards:
scoreboard objectives add damageTaken minecraft.custom: minecraft.damage_taken
scoreboard objectives add damageDealt minecraft.custom: minecraft.damage_dealt
So you then ask if someone has taken damage, or has done damage:
execute if entity @a [scores = {damageTaken = 1.}] run tag @a [scores = {damageDealt = 1.}, distance = .6] add hdHITTER
execute if entity @a [scores = {damageDealt = 1.}] run tag @a [scores = {damageTaken = 1.}, distance = .6] add hdHITTED
Then the eigendliche process can start, heal the player. And thus the part of which I have no idea how to realize it.
You now have a scoreboard that shows the damage dealt. You'd have to rework that in a way that would cure you for just that amount of heart, which is not an easy task in Minecraft. I only know how to do the exact damage, maybe that will give you something:
execute as @a [tag = hdHITTER] at @s run summon spectral_arrow ~ ~ 2.3 ~ {Duration: 0, Motion: [0.0, -1.0.0.0], pickup: 0b, damage: 0, Tags: ["dmg"] }
execute as @e [type = spectral_arrow, tag = dmg] at @s store result entity @s damage int 1 run scoreboard players get @p damageDealt
At the end, everything still be reset:
scoreboard players set @a [scores = {damageTaken = 1.}] damageTaken 0
scoreboard players set @a [scores = {damageDealt = 1.}] damageDealt 0
tag @a remove hdHITTER
tag @a remove hdHITTED
Maybe that helps you, tell me, if you need something else.
Many Thanks
I still have such a question and how can it do that the scoreboards are reset automatically if I do not just do harm or suffer?
Even with because of tags.
Well, that works with those here:
scoreboard players set @a [scores = {damageTaken = 1.}] damageTaken 0
scoreboard players set @a [scores = {damageDealt = 1.}] damageDealt 0
tag @a remove hdHITTER
tag @a remove hdHITTED
As it stands. Or do you mean something different?