Enchantment crashes when used

Started by D1athForYou on

Topic category: Help with modding (Java Edition)

Last seen on 13:55, 4. Jun 2024
Joined Jun 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Enchantment crashes when used

https://pastebin.com/ZrbSbxAk (error log)

when i sue the attack "Full Counter" enchantment on any mob i wanted it to damage the mob the amount it hit me and heal me back instantly(basically spike enchantment but on a sword) but when the npc hits me the game crashes.

 

Last seen on 14:57, 22. Jun 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The problem is that 'get…
Mon, 06/03/2024 - 15:24

The problem is that 'get entity event/target entity is targeting' returns a null entity if the target isn't attacking anything. In this case, the event/target entity is the one being attacked; so if you attack an entity that isn't targeting you, it will return a null entity and crash the game. (I'm not totally sure that's how you want this to work- you might need to use the source entity instead.) If you add an if bracket that checks that the targeted entity exists, that should fix the problem.