How to make a charming effect

Started by Rizzard on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a charming effect
Wed, 01/29/2025 - 14:38 (edited)

Hello, so i made this  https://imgur.com/a/qgC5tPs

It just launch me towards the entity, is there a way to make me walk slowly instead?
Like in ice and fire with the sirens for exemple

(Edit : Rizzard is the name of the entity)

Edited by Rizzard on Wed, 01/29/2025 - 14:38
Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can decrease the…
Thu, 01/30/2025 - 01:34

You can decrease the strength of the attraction by multiplying the vx, vy, and vz parameters by some constant like 0.1.

You should set the nearest entity as a local variable instead of copying it three times. It will remove redundant code and make it less resource intensive. I would also recommend using "Push [] with dx, dy, dz" instead of "Override motion vector ..." because it tends to be less janky (from limited experience).

Joined Jan 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok, i changed to this, to…
Thu, 01/30/2025 - 16:12

ok, i changed to this, to try to get 3 small impulses towards the entity, but i really don't get why i doesn't work anymore , the projectile hits me, and it grabs me maybe 1 time out of ten, an only on impact never after the 40 ticks https://imgur.com/a/3VT06Cf (and i didn't really get what you said with using the nearest entity as a local variable)

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah I see I thought this…
Fri, 01/31/2025 - 05:40

Ah I see I thought this procedure was being called every tick.

In that case, you could have the projectile cause a custom potion effect or toggle a player variable, and then have that procedure be called every tick (or every some number of ticks) that it is active. Here's how you could do that:

Using variables:

  1. Go to the "Variables" tab on the right sidebar in the workspace
  2. Click "Add new variable"

    1. Create a variable with any name (attracted_ticks_remaining in this example) with type number with the scope of PLAYER_LIFETIME

    https://imgur.com/a/DDfimWO 

  3. Go to the procedure that is triggered when the projectile hits an entity. Set the new variable to 20 times the amount of time you want to attraction to last for the Event/Target Entity.

    https://imgur.com/a/anTsHXT 

    (First half of post since I can't figure out why McCreator's not letting me post the entire thing)

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(4.) Create a new procedure…
Fri, 01/31/2025 - 05:41
  1. (4.) Create a new procedure with global trigger On entity tick update
    1. Check if the variable is greater than zero. If it is, decrease the variable by zero and use the attraction procedure.
    2. Note I'm finding the distance between the entities and then dividing that from the dx, dy, and dz to normalize the attraction force, basically so that it doesn't get weaker the closer you get.
    3. (Optional, but fair warning) Checking for nearby entities constantly every tick is not good for performance. A rather complicated workaround is to set the UUID of the entity that shot the projectile as a string variable and access that through custom code snippets or commands. COMMANDO66's comment from https://mcreator.net/forum/98579/ways-store-entity-or-its-uuid-variable explains using UUIDs and commands a bit further.

Your procedure might now look something like this: https://imgur.com/a/sEcRYRE (Unfortunately by force of habit I named everything using snake_case. The variables should really be in camelCase)

Here's the procedure if you just wanna download it: https://limewire.com/?referrer=48k1433kko (the file share expires in 7 days)
Beware: there could very well be mistakes.

Using potion effects:

  1. This is basically the same method as above, but instead of keeping track with variables, we use potion effects. Create a new potion effect, and give the entity hit by the projectile that potion effect for some amount of time.
  2. In the On effect active tick trigger of the potion effect, call the attraction procedure.
    1. The warning / optional tip is the same as before.
       

As for using local variables to keep track of the entity, create a local variable using the right side bar in any procedure. You can have an entity local variable and set it to the nearest entity of some type without needing to find the nearest entity more than once.