Help with making every entity that attacks the player get an effect.

Started by varuniemcfruity on

Topic category: Help with modding (Java Edition)

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with making every entity that attacks the player get an effect.

Help with making every entity that attacks the player get an effect.

I'm working on a mod using MCreator, and I'm trying to implement a new feature where players can eat a special food item that grants them temporary protection against enemy attacks. Specifically, I want to apply the wither effect to any entity that attacks the player for 2400 ticks after they consume the food item.

To achieve this, I've already created a procedure in MCreator and set it to trigger after the player eats the food item. However, I'm not sure how to proceed from there. Can someone please help me figure out how to apply the wither effect to attacking entities for the specified duration? Any guidance or advice would be greatly appreciated!

Last seen on 11:24, 4. May 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
make logic player lifetime…
Sat, 04/08/2023 - 18:36

make logic player lifetime variable. then in that item triggers find: if player finished using item and add procedure, in that procedure do next: set "your variable" to true, then add wait 2400 ticks on server side then set "your variable" to false

another procedure. set if entity attacked in global triggers, then add if get "your variable" for event/target entity = true, add potion to source entity procedure block

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
when i put set "my variable"…
Sat, 04/08/2023 - 19:56

when i put set "my variable" to false in wait 2400 ticks on server side do i get a error saying "statement do does not support local variables"

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nvm i didnt realize i was…
Sat, 04/08/2023 - 20:56

nvm i didnt realize i was supposed to use a player lifetime variable

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok so i just tested it out…
Sat, 04/08/2023 - 21:14

ok so i just tested it out and if any mob attacks another mob they get wither, it doesnt matter if they ate the food

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
nvm i made some changes and…
Sat, 04/08/2023 - 21:23

nvm i made some changes and got it working thanks so much