Floating Items

Started by Pokealamine on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Floating Items

I have seen many people have issues with making an item that floats—above the void and item floating in general—so here is a tutorial!

Here is the Imgur link to my example: https://imgur.com/a/UHEFGv7

Explanation of each line:

(the global trigger "on entity tick update" can be demanding on some systems, but is required to make sure that this procedure works)

1: is (Event/Target entity) (sub) type of item)

-This line checks that the entity it is attempting to run the procedure on is an item, and this can be swapped to any other entity

(the procedure part can be found easily by typing "sub" into the procedure search bar)

2- is (Convert Item entity (Event/target entity) to itemstack) tagged in item tags as "ev:enderite"

-This line compares the item against a tag, to see if it falls within that tag, and if so, the procedure continues

(the red part "convert item entity (event/target entity) to item stack, converts the item entity to an item that you can use item-based procedures on)

(instead of checking against a tag, you can check against a specific item) Ex: https://imgur.com/a/D15lKvO

3: 4>=Y position of (event/target entity)

-This line checks to see what the Y position(vertical height) of the item, and allows the procedure to continue if the y position of the item is equal to or less than 4

4: Attempt to override motion vector of (event/target entity) to vx: 0 vy: 0.15 vz: 0

-This line attempts to change the motion of the item so that it has no movement, left, right, forward, or backward, and has a little boost upward

(the point of the procedure in this case is to make items float above the void, instead of falling into it; so the little boost in vertical height is to cancel out the downward momentum, and to bring it up a few blocks to about y=10)

 

5: Set no-gravity of (event/target entity) to true

-This line is ultimately what makes the item float, by removing its gravity

Here is a link to the full procedure that I use in my mod: https://imgur.com/a/wzpGkNq

(The extra parts are just an initial check to see if the item is entering the void in each dimension, to make sure the procedure is doing more than it needs to, when not near the void)

(the "Pather" is a custom dimension in my mod, it is not a vanilla dimension"