How to make a weapon that spawns an entity when an entity is hit that attacks the entity that got hit by the weapon.

Started by DarkParty on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a weapon that spawns an entity when an entity is hit that attacks the entity that got hit by the weapon.

Long title, I know. So I need to know how to make a weapon that, when it hits an entity, spawns a vanilla entity that attacks the victim entity. I have not been able to do this cause both the spawned entity and the victim entity would be "Event/Target Entity."

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm pretty sure that there…
Wed, 12/03/2025 - 13:43

I'm pretty sure that there is a procedure block to spawn an entity and get its reference, or something like that. You could make a local entity variable, then set it to spawn a vanilla entity and get its reference, then check that it is not null, or check that it is a living entity (to avoid crashing the game). Then you can use the variable to refer to the newly-spawned vanilla entity instead of event/target entity, which will refer to the victim.

 

I think. I can't remember the precise name of the procedure block, and I haven't used it a lot, so I could be getting something wrong.