Magnet block that pulls in items

Started by swelkinn_n on Sat, 11/19/2022 - 20:57

Topic category: Help with modding (Java Edition)

Last seen on 04:21, 29. Jan 2023
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Magnet block that pulls in items
Sat, 11/19/2022 - 20:57

I'm trying to make a block that pulls in dropped items, which I know at least was possible, which leads me to assume it still is, but I'm not sure how.

The reason I know it was, was because of this video at the timestamp this link sends you to, as the person stated in a comment that this is all procedures, and no custom code. I'm not sure of what they did, but I would love to know if anyone has a method, especially with all the newer procedure blocks in the program now

Last seen on 16:27, 27. Jan 2023
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Ironically, I spent a fair…
Mon, 11/21/2022 - 00:04

Ironically, I spent a fair bit of time trying to make a block that launches everything away from it. Presumably, doing the reverse should work to make it a magnet:

  • Make a procedure that runs an entity iterator in your desired radius around the block every tick.
  • Make some custom variables for x, y, and z offset. (I'll call them Sx, Sy, and Sz)
  • If the entity iterator's x coordinate is less than the block's x coordinate, set Sx to something positive. If it's more than the block's x coordinate, set Sx to something negative. The amount you set it to will determine how rapidly the magnet pulls stuff in. (Anything greater than 1 will launch stuff pretty forcefully, enough to deal fall damage to entities.) You might also want to check that the entity iterator isn't too close, otherwise the magnet will continue to pull stuff even if it's right next to it.
  • Do the same thing for the z and y coordinates.
  • Attempt to override the entity iterator's velocity. If you want the magnet to pull stuff at consistent speeds, just set the x y and z values of the override block to the custom variables you made earlier- this will make anything in the radius immediately move at a consistent speed towards the magnet. If you want stuff to gradually accelerate, you can instead set x y and z to the current velocities of the entity iterator, plus your custom variables. This will make anything in the radius adjust its velocity towards the magnet based on how powerful the magnet is and how long they're nearby it.