Making black hole/ orb pulls entities into it

Started by Aplhau on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Making black hole/ orb pulls entities into it
Fri, 07/09/2021 - 16:53 (edited)

Hello hope everyone is having a nice day. I need some help with making an orb the spawns where the cursor is and entities start to get pulled into it and it despawns after 5 seconds. I have figured out how to spawn the orb where the cursor is. I have a procedure that pulls entities in but I don't know if it is ok because it looks like it teleports the entities to Narnia. If this way works can you tell me how to make it slower.

this is the procedure im using. the bottom if statement is for it to despawn after 5 seconnds

Edited by Aplhau on Fri, 07/09/2021 - 16:53
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
easiest way: create 3 or 4…
Fri, 02/07/2025 - 11:42

easiest way: create 3 or 4 number variables

dx = X position of event target - X position of iterator

dy = Y position of event target - Y position of iterator

dz = Z position of event target - Z position of iterator

speed = (the higher the number the lower the speed)

then

Attempt to override motion vector

x= dx/speed

y= dy/speed

z= dz/speed

 

dont forget to make it on entity tick update (or player) well idk its just supposed to be on tick update

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Doesn't using [pos of puller…
Sat, 05/10/2025 - 23:18

Doesn't using [pos of puller - pos of pulled] result in a stronger attraction the farthest away from the puller you are? Doesn't it make the attraction very weak up close? I need it to be the other way around.

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes. To fix this, you can…
Sun, 05/11/2025 - 05:24

Yes. To fix this, you can normalize the vector by dividing it by the magnitude.
Let's start with this:

vx = X position of desired center point - X position of entity iterator

vy = Y position of desired center point - Y position of entity iterator

vz = Z position of desired center point - Z position of entity iterator

magnitude = sqrt[(vx ^ 2) + (vy ^ 2) + (vz ^ 2)]

Next, we assign values to new variables with the normalized versions of vx,y,z.

Nvx = vx / magnitude

Nvy = vy / magnitude

Nvz = vz / magnitude

Now we have our normalized vector, which has a length of exactly 1.
If you want to make the attraction stronger as you near the center, we can make a "force" variable that changes based on the magnitude(distance). We will also add "maxForce" and "rate" variables to adjust the behavior to our liking. The maxForce variable will determine how quickly the target will move when it is exactly in the center, and the rate will determine the intensity of the increase in speed. SLIGHTLY higher rate = MUCH more dramatic change in speed. I recommend staying in the range of 0.03 to 0.05.

 

force = maxForce * [(1 + rate) ^ (magnitude * -1)]

All that's left is to reassign the values of vx,y,z to get our final result.

vx = Nvx * force

vy = Nvy * force

vz = Nvz * force

 

There we have it! Our movement vectors are complete. Make sure that you run new calculations each tick for all of the dynamic variables.