We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

8

Player NBT - Looking At

5 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 2
    Registered User commented
    Comment actions Permalink

    I would love this as well. It would open a lot of possibilities.

  • 0
    Registered User commented
    Comment actions Permalink

    This is actually doable with commands. You need to summon an armor stand facing the same direction as the player, and teleporting it (inside of a tick) until it hits a block.

    Would be cool if they added an official feature, though

  • 0
    Registered User commented
    Comment actions Permalink

    This way you must wait some time for armorstand to reach block and if you are looking the very corner it can miss this block

  • 0
    Registered User commented
    Comment actions Permalink

    If you use a function loop, something like

    execute as @p[scores={foo=0}] run function file:function

    File:function being

    execute as @e[type=armor_stand] at @s run tp ^0.1 ^ ^ (dunno if this is correct)
    execute as @e[type=armor_stand] at @s if block ~ ~ ~ air run scoreboard players set @p foo 1
    execute as @p[scores={foo=0}] run function file:function


    This way, the armor stand will be teleported forward until it hits a block, all during a game tick (1/20 of a second). Obviously you need to set some restrictions, to prevent a softlock if you look in the air (this would make the loop endless, since the armor stand would never reach a block)
    About the precision, you can adjust the ^0.1 value to a lower value, making it more precise.

    Anways i can't deny that having a nbt tag for this could make things really easier.

    I was just saying that it is already possible to do this, even if it's really clunky

  • 1
    Registered User commented
    Comment actions Permalink

    I also really need this feature. I think it could be made into a predicate. Although it can be achieved using ray casting at present, this method is not perfect because it cannot handle blocks that have an Interaction Box but whose Interaction Box does not occupy a whole block.