[tutorial/example] How to get the entity the player is look at [procedures]

Started by SuperGumo on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2025
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[tutorial/example] How to get the entity the player is look at [procedures]
Thu, 06/19/2025 - 20:28 (edited)

may my text contain errors cuz english is my second language.

 

hi, recently i started to make a mod of the anime rezero as a hobby, and the first skill that i've wanted to add were the Shamak. For those who don't know, the Shamak is a magic that inhibits the senses of the target, and i wanted to make this with the entity that the player was looking at.

I'm making this mod using only my head and a little help of ChatGPT (that, tbh, doesnt help me that much, they constantly tell me to use blocks that doesnt exist) so i searched a little on the blocks and i've noticed that there's no block to get especifically what i've wanted, i've asked for help to chatGPT and they just tell me to use their imaginary blocks, then i searched in the web, but the maximum that i reached was a titan procedure that could even not work on my little project, so i searched and i've find a easier way to do this.

basically, we will need four blocks:

() = notes

[] = blocks

 

"Get nearest entity at x: y: z: in a square cube with size [4¹] of type [your chouce]"            (can be find on world procedures > data)
"Look X position of [event/target entity (the player)] with raytrace distance [5²] fluid mode [NONE] block mode [OUTLINE]" and it's Y 'n Z variants.

 

¹you can modify the [4] to make the "aim" more or less precise, for my example, i've decided to continue with [4] bc it's a magic and i want to the player be able to spell them correctly on the target even when they're moving really fast.

²you can modify the [5] to make the "aim" shoot more or less distant of the player, for example, if you want something that could be affect an entity that is really distant from the player, you should choose a bigger number, if you want somethin that only works for entities that are really touching the player, you should choose somethin' like 1 or 2.

so, just insert the look x/y/z[...] on each empty space (x on x, y on y, come on, you can do this) and you have the entity that the player is lookin'

 

if you have a better way to do this, feel free to share with us, but this was the the way i founded to do this without exploding my computer. (thank you for reading :))

 

Edited by SuperGumo on Thu, 06/19/2025 - 20:28