How to retrace to get the block the player is looking at.

Started by tbroski on

Topic category: Help with Minecraft modding (Java Edition)

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to retrace to get the block the player is looking at.

Hi, I am trying to figure out how to [Get a block] from afar by raytracing. I see the [Entity look x/y/z position - raytrace distance]->[<Number Argument>] block in the Entity procedure category but am unsure how the number argument works, does it get the block the number argument away. Can someone please help me with this? Thanks!

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is there a way to trace the…
Wed, 01/29/2020 - 20:13

Is there a way to trace the first non-air block?

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did u ever figure out how to…
Fri, 07/03/2020 - 01:05

Did u ever figure out how to test for the first non air block, I am trying to do the same

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes lol, I have used in java…
Fri, 07/03/2020 - 01:11

Yes lol, I have used in java code;

World::rayTraceBlocks

But I believe there is a procedure block for the above in MCreator.

Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Just try make it 1000 blocks…
Fri, 07/03/2020 - 01:22

Just try make it 1000 blocks

 

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Just in case someone finds…
Sat, 09/05/2020 - 07:18

Just in case someone finds this, the Raytrace traces a line on that axis, returning the block coordinates at the block distance (the number in the coding block). If you wanted to scan, you could make a local variable, and increment it until you found a non-air block. Then use the break loop block under flow control. Actually quite simple, but  was goofing with the jaw, degrees, etc. until I realized how raytrace worked. The block directly in front (where a mob is facing) then use [x raydistance 1] and [z raydistance 1] and [y] the mobs y.

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@kreatorKen Do you have the…
Fri, 07/15/2022 - 09:07

@kreatorKen Do you have the blocks for this? I'm trying to figure it out, but it's not too easy to understand what you said. I hope you'll react. Thanks already

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here is a tutorial I made:…
Fri, 07/07/2023 - 19:09

Here is a tutorial I made: link