how do i make a enemy that can only be damaged by a custom sword

Started by Just_A_Random_Dude on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how do i make a enemy that can only be damaged by a custom sword

So I'm making a custom Entity and i wanted it to only be damaged by a custom weapon i made, but i want a variable that needs to be true to be able to attack the Entity.

 

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use the on entity hurt…
Mon, 06/15/2026 - 08:06

Use the on entity hurt global trigger, not on the entity, then check entity is type your_custom_entity. Check if item in main hand of source entity does not = sword OR variable = false, then cancel trigger.

This will mean that the player must use the sword and the variable must be true to deal damage to it