Java to SK - Hand Location

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

AsuDev

VIP
Jan 27, 2017
241
22
18
24
United States
Category: Java to SK conversion

Suggested name: Hand Location

What I want: A simple conversion from Java to Skript (getting hand location).

Ideas for commands: None

Ideas for permissions: None

When I'd like it by: Asap

Basically what I want is a function from java to be converted to a function in SK. It's mostly the math part I'm struggling with, but I would be happy if someone did this for me.

Here is the java part: https://pastebin.com/9MdBCpyM
 
code_language.skript:
on load:
    set {PI} to eval "pi"

function getHandLocation(player: player) :: location:
    set {_loc} to {_player}'s location
   
    set {_a} to yaw of {_loc} / 180 * {PI} + {PI} / 2
    set {_l} to sqrt(0.8 * 0.8 + 0.4 * 0.4)
   
    set x coord of {_loc} to x coord of {_loc} + {_l} * cos({_a}) - 0.8 * sin({_a})
    set y coord of {_loc} to y coord of {_loc} + (distance between {_player}'s location and {_player}'s eye location) - 0.2
    set z coord of {_loc} to z coord of {_loc} + {_l} * sin({_a}) + 0.8 * cos({_a})
   
    return {_loc}

Requires only Skuared (skript-math).
 
Last edited: