#How to stop someone from dying when they would have been killed (with a certain weapon/tag)
1 messages · Page 1 of 1 (latest)
Does the weapon actually need them to not die, or do you just need to run commands as them when they die?
Cause you can do the latter
You could make the weapon have the totem of undying component and then just give the item back.
I have misworded this, sorry! 😅 I meant to say that i need the person killed by the item not to die. There will be some special effects, then they will be put in spectator. Does anyone know if this is possible? I was thinking about setting immediate respawn to true really quickly then teleporting them to their death location.
In that case then yes as HeDeAn said, you can give the item a death_protection component so that it behaves like a totem of undying, and just detect when that gets used via an advancement to run a function that does whatever you need
i
am the smartest man alive
i meant to say the person killed by the item
sorry again man
You can do that with a custom enchantment. more specifically with the post_attack effect.
make the item deal 0 damage, and in the effect, target the hit player and run a function. That function compares the players health and how much damage it would deal. If the if the the damage would kill the player run a different function instead if it doesn't, just run a damage command.
This method has some slight drawbacks, like it can't easily increase the damage with sharpness or other enchantments unless you specifically program that in or the damage/health comparison can't easily calculate the targets armor protection and overall damage reduction.
Can't you detect the origin of death through advancement and target @s in the reward function ?
Yes, but they don't want or need to have the player die
yeah no that is how it is
wait
how do you select the attacker in entity_killed_player?