How do I disable a player's damage to other entities? [SOLVED]

Started by benl4b on

Topic category: Help with modding (Java Edition)

Last seen on 09:40, 26. Jul 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I disable a player's damage to other entities? [SOLVED]
Fri, 10/27/2023 - 13:01 (edited)

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
Last seen on 22:20, 20. Jul 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here's the solutions, clean…
Fri, 10/27/2023 - 00:09

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.""

Last seen on 20:37, 26. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could first make either…
Fri, 10/27/2023 - 01:00

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.

Last seen on 20:37, 26. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, didn't reload the…
Fri, 10/27/2023 - 01:01

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.

Last seen on 09:40, 26. Jul 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thx i will try it
Fri, 10/27/2023 - 12:59

Thx i will try it

Last seen on 09:40, 26. Jul 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
WOW this is really good! It…
Fri, 10/27/2023 - 13:32

WOW this is really good! It works perfectly!!! THX

Last seen on 22:20, 20. Jul 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No problem, happy to help!
Fri, 10/27/2023 - 20:40

No problem, happy to help!