The Meaning of Life, the Universe, and Everything.
Join Date:
2/20/2019
Posts:
46
Member Details
I made a command that is supposed to test for a mob that died but i'm not sure the best way to do it.
my command is /execute as @e[type=zombie,nbt={Health:0F}] run effect give @p fire_resistance 90 5
for some reason it doesn't do anything when I kill the zombie.
EDIT:I just tested the "nbt=" part with multiple different nbts and none of them worked. My nbt selector seems to be broken :(.
EDIT2: the "nbt={Health:0F}" part seems to work when I change the number to anything except 0 I tested it by simply summoning zombies with different "Healths".
The Meaning of Life, the Universe, and Everything.
Join Date:
2/20/2019
Posts:
46
Member Details
I also tried putting the zombie on a team that I made and doing /execute unless entity @e[type=zombie,team=<the team that I created>] with a repeating command block constantly adding the zombie to a team.
The Meaning of Life, the Universe, and Everything.
Join Date:
7/13/2019
Posts:
54
Member Details
You may have to keep the data of the mob's HP in a scoreboard, and constantly update it until it reaches zero. There are some old posts in this wiki on the matter.
store the hp into the objective (run this in a loop):
/execute as <entity> run execute store result score data hp run data get entity @s Health
"data" is a fake player which I'm using to store the value. The reason you can't use the entity itself is that it has to be alive in order for the command to retrieve the value from its objective. Now you can use :
/execute if score data hp matches 0 run ...
or if you don't want to write all of that, you could use the 'unless'
statement to check if the entity exists and if not, apply the effect and tag the player.
/execute unless entity <entity> run effect give @a[tag=!hasEffect] ...
/execute unless entity <entity> run tag <player> add hasEffect
The Meaning of Life, the Universe, and Everything.
Join Date:
2/20/2019
Posts:
46
Member Details
if I one-shot the zombie or do a bunch of crits to kill it then the health bar will remain at 20. for example i'll kill it in one shot (with a 1000+ attack damage sword) it doesn't go down to 0 it remains at 20 do you know how to fix this?
if I one-shot the zombie or do a bunch of crits to kill it then the health bar will remain at 20. for example i'll kill it in one shot (with a 1000+ attack damage sword) it doesn't go down to 0 it remains at 20 do you know how to fix this?
I tried it with a normal sword and it became a 0. Use the second method then.
The Meaning of Life, the Universe, and Everything.
Join Date:
2/20/2019
Posts:
46
Member Details
Hmmm the killing the zombie and executing the command part doesn't seem to work.
I have a repeat always active unconditional command block with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run tag @a add <my tag>
and I have a chain conditional always active command block attached to it with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run effect give @a[tag=!zombie] fire_resistance 90 5
Hmmm the killing the zombie and executing the command part doesn't seem to work.
I have a repeat always active unconditional command block with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run tag @a add <my tag>
and I have a chain conditional always active command block attached to it with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run effect give @a[tag=!zombie] fire_resistance 90 5
The tag is there to stop the effect from being applied all the time. It doesn't work because you're adding the tag in the first command which prevents the second command from adding the effect to the player. Switch the commands and it should work.
The Meaning of Life, the Universe, and Everything.
Join Date:
2/20/2019
Posts:
46
Member Details
Ok so I switched the commands and it seems to work when I do the command with the "!" in front of the tag and it will give me the effect until I remove the "!" but when remove it and kill the zombie nothing happens.
Ok so I switched the commands and it seems to work when I do the command with the "!" in front of the tag and it will give me the effect until I remove the "!" but when remove it and kill the zombie nothing happens.
Why would you remove the exclamation point? it is there for a reason. If you want to set this up for multiple uses, then you should use the scoreboard system with the built-in criteria.
I made a command that is supposed to test for a mob that died but i'm not sure the best way to do it.
my command is /execute as @e[type=zombie,nbt={Health:0F}] run effect give @p fire_resistance 90 5
for some reason it doesn't do anything when I kill the zombie.
EDIT:I just tested the "nbt=" part with multiple different nbts and none of them worked. My nbt selector seems to be broken :(.
EDIT2: the "nbt={Health:0F}" part seems to work when I change the number to anything except 0 I tested it by simply summoning zombies with different "Healths".
I also tried putting the zombie on a team that I made and doing /execute unless entity @e[type=zombie,team=<the team that I created>] with a repeating command block constantly adding the zombie to a team.
You may have to keep the data of the mob's HP in a scoreboard, and constantly update it until it reaches zero. There are some old posts in this wiki on the matter.
How would I do that?
create the objective:
store the hp into the objective (run this in a loop):
"data" is a fake player which I'm using to store the value. The reason you can't use the entity itself is that it has to be alive in order for the command to retrieve the value from its objective. Now you can use :
or if you don't want to write all of that, you could use the 'unless'
statement to check if the entity exists and if not, apply the effect and tag the player.
Command block engineer // Developer // #TeamTrees
if I one-shot the zombie or do a bunch of crits to kill it then the health bar will remain at 20. for example i'll kill it in one shot (with a 1000+ attack damage sword) it doesn't go down to 0 it remains at 20 do you know how to fix this?
I tried it with a normal sword and it became a 0. Use the second method then.
Command block engineer // Developer // #TeamTrees
Hmmm the killing the zombie and executing the command part doesn't seem to work.
I have a repeat always active unconditional command block with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run tag @a add <my tag>
and I have a chain conditional always active command block attached to it with: /execute unless entity @e[type=zombie,name="Undead Warrior"] run effect give @a[tag=!zombie] fire_resistance 90 5
The tag is there to stop the effect from being applied all the time. It doesn't work because you're adding the tag in the first command which prevents the second command from adding the effect to the player. Switch the commands and it should work.
Command block engineer // Developer // #TeamTrees
Ok so I switched the commands and it seems to work when I do the command with the "!" in front of the tag and it will give me the effect until I remove the "!" but when remove it and kill the zombie nothing happens.
Why would you remove the exclamation point? it is there for a reason. If you want to set this up for multiple uses, then you should use the scoreboard system with the built-in criteria.
Command block engineer // Developer // #TeamTrees
Ohhhhh I guess didn't realize it was one use my bad.
Not sure if this is what you need but here's a system which detects when you kill any zombie and gives you the effect.
create the objective using the built-in criteria:
repeating, always active command block:
chain, conditional, always active command block:
Command block engineer // Developer // #TeamTrees
Awesome! thanks for all the help!