Сoordinates, relative to player's view

Discussion in 'Plugin Development' started by l_MrBoom_l, May 29, 2020.

  1. Offline

    l_MrBoom_l

    Hello, my server is almost a year old, and I'm trying to create some exclusive cosmetics for those, who joined for the first time in the summer of 2019. This is a star made of flame particles that should be above the player’s head and rotate relative to his yaw. I summoned an invisible armor stand that always teleports to the player, copies player's yaw but saves the pitch == 0.0f, and I made a prototype using command blocks, which summon particles at the armor stand at the coordinates like ^0.2 ^2.2 ^. Is it possible to get same coordinates which dependent on player's position and yaw (but with pitch == 0.0f) in java code?

    Commands from the command blocks, if needed:
    Code:
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^ ^2.6 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^ ^2.4 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^0.2 ^2.2 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^-0.2 ^2.2 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^0.2 ^2.6 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^-0.2 ^2.6 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^0.3 ^2.6 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^-0.3 ^2.6 ^
    execute at @e[type=minecraft:armor_stand,tag=str1] run particle minecraft:flame ^ ^2.8 ^ 
    (Sorry if my English is bad)
     
  2. Offline

    Machine Maker

  3. Offline

    l_MrBoom_l

    It changes location by x y z, I need to change the location by the direction (yaw and pitch), I need an alternative or an implementation of yaw and pitch dependent coordinates. I need to somehow use coordinates like ^ ^1.62 ^5 in java code. Is it possible?
     
  4. Offline

    bowlerguy66

    @l_MrBoom_l Couldn't you get the angle of either the yaw/pitch and use sin & cos?
     
  5. Offline

    l_MrBoom_l

    Sorry, I didn't learn how to do something like I need. Can you tell me how can I do it?

    Marking as closed, my solution if someone needs:
    Code:
    Location l = player.getLocation();
    double ax = l.getX();
    double ay = l.getY();
    double az = l.getZ();
    
    double x = ax + 0.2 * Math.cos(angle);
    double y = ay + 2.2;
    double z = az + 0.2 * Math.sin(angle);
    is same as ^0.2 ^2.2 ^ in minecraft.


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2020
    bowlerguy66 likes this.

Share This Page