Started by
benl4b
on
Topic category: Help with Minecraft modding (Java Edition)
Hey!
I've been looking for a solution for a while on how to disable a player's damage against other various entities.
Means: You should still be able to do damage, but not to specific entities, neither with weapons and bows, melee or anything else.
But they must not be immortal so that they can be killed by mobs or any other opponents.
Edited by benl4b on Fri, 10/27/2023 - 13:01
Here's the solutions, clean and simple. That big cancel block is found under "advanced" in the code block options, and where I have "type of zombie" selected you would put the entity you want to be immune to player attack.
You could first make either a potion effect or a player-persistent logic variable to tell when the player has this effect, and when they don't. Then, make a procedure with the global trigger 'before entity is hurt,' to check if the source entity is both a player, and has this effect; AND that the event/target entity is of a type they're not allowed to damage. (You could do this with an entity tag). If they are, you could try canceling the global trigger, or just immediately healing the event/target entity for the damage amount.
...Or you could just give the player a high-level ambient weakness effect, but this wouldn't allow you to discriminate between different types of entities.
Sorry, didn't reload the page and see PhatBoi's comment. That should work, you'd just want to also include a check for your effect and a check that the event/target entity is the type you want.
Thx i will try it
WOW this is really good! It works perfectly!!! THX
No problem, happy to help!