Advice for custom sword enchantment (dealing extra damage to specific mobs)

Started by Ferfle Fleef on

Topic category: Help with Minecraft modding (Java Edition)

Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Advice for custom sword enchantment (dealing extra damage to specific mobs)

I'm relatively new to MCreator and I've been working on a custom enchantment called "Defusal" which is meant to deal extra damage to creepers. Below is a screenshot of the procedure I have for the effect:

Screenshot of Procedure

(I fit as much into frame as I could. The bit at the end is "provided damage source.")

Currently this crashes the game whenever I attack a creeper. Any advice on what I should do to fix this?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Changing 'entity attacked'…
Tue, 11/07/2023 - 05:08

Changing 'entity attacked' to 'before entity is hurt' for the global trigger might help. The other thing is that the 'get damage of item in main-hand' of function does not get the attack damage of an item, but rather, the durability loss of that item. (The game is probably crashing because when you first use an item, it has 0 durability damage, and is thus trying to do zero attack damage to an entity.)

You can basically just remove the attack damage of the sword anyways, as this will be dealt anyways in addition to whatever you add on to it. If you're using the 'before entity is hurt' trigger, it also provides an 'amount' dependency that you can use to get the attack damage dealt, if you still want to double it. 

Also, welcome to the program! It's an easy mistake to make, and your code otherwise looks really good!

Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I got it working now. Thanks…
Tue, 11/07/2023 - 14:53

I got it working now. Thanks for the help!

Joined Aug 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It works, but i ran into a…
Sat, 08/31/2024 - 16:33

It works, but i ran into a major problem, the enchantment didn't take in combat speed, so I could just spam click and deal the same amount of damage, does anyone have a fix for it?