Is there a possibility to reflect the damage by custom coding?

Started by mouwwie on

Topic category: Help with modding (Java Edition)

Last seen on 10:28, 1. Feb 2021
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is there a possibility to reflect the damage by custom coding?

Two things I'll say right away: I'm not a native English speaker, so there might be mistakes. Also I have no experience with coding whatsoever, to be honest, I am quite a noob in modding for now :)

So I want to add the feature: when the mob is attacked, any damage that is given to it reflects on the player, so the player takes the damage too. I know you can't do that by using standart MCreator features, but is it possible to do so by custom coding?

If it is possible, can anyone help me with that? I'm not sure what can I do in exchange, but I might try and help with ideas, if you want :)

Last seen on 05:29, 31. Jan 2022
Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
One way you can try is…
Sat, 01/25/2020 - 05:39

One way you can try is create a custom armor that has thorns enhancement and let the mob wear it.

Another way requires a tiny bit of modification on the generated code from mcreator. When you create the mob, create a procedure for "When entity is hurt" and use it as if the passed "entity" is the attacker. Save the mob elements and let mcreator generate and build. Then change a few lines of the generated code of the mob element to let it pass to your "When entity is hurt" procedure the attacking entity instead of the mob itself.