8 Frame
bi0qaw edited this page 2017-11-25 20:04:08 +01:00
frame of %entity%

Creates a frame from an entities orientation. Returns a frame object.

frame with yaw %number% and pitch %number%

Creates a frame with a custom yaw and pitch. Returns a frame object.

%vectors% in %frame%

Converts the vectors from the Minecraft coordinate system to the frame coordinates. Returns a new list of vectors.

frame yaw of %frame%
frame pitch of %frame%

Yaw and pitch of a frame.


Frames are used whenever you want to change the direction of a bunch of vectors. Instead of rotating the list of vectors you can just grab a frame and let it do the correct rotations. This is best shown with a small example:

The two images show each a player with a particle circle around his head. The nice thing is that the particle circle follows the rotation of the player's head. To reproduce this effect you can execute the following script:

command /halo:
    trigger:
        set {_frame} to frame of player
        set {_circle::*} to circle with radius 1 and density 5
        set {_rotated-circle::*} to {_circle::*} in {_frame}
        set {_circle-locations::*} to location 1 above player's head offset by {_rotated-circle::*}
        show happy villager at {_circle-locations::*}

All the magic happens in lines 3 and 5. In line 3 we grab the frame of the player and in line 5 we rotate our vectors with the frame. A frame is nothing else than a mini coordinate-system, in our case the coordinate system of the player's orientation. The expression %vectors% in %frame% just tells Skript to use the coordinate system of the frame instead of the standard Minecraft coordinate system. This is illustrated by the following picture where the flame particles indicate the three axes of the frame.

You can see that the circle is still in the "horizontal" XZ-plane but the whole coordinate system is rotated.


When should I use frames?

  • When you need the same shape in multiple directions
  • When you need to update the direction of a shape over and over again
  • When you need to rotate a lot of points
  • When you feel it is more convenient than a rotation

Note that frames do not completely replace rotations. I tend to use rotations during the creation stage of a shape and then get the final orientation with a frame. Let's illustrate this with the example of the circle around the player's head. What if want a circle that goes vertically around the player's head and not horizontally? It is possible to achieve this with frames only but you will have to deal with a lot of annoying yaw/pitch problems. The solution to this is that you first get a vertical circle with the help of a rotation and then show it in the frame of the player:

set {_circle::*} to circle with radius 1 and density 5 # Creates a circle in the horizontal XZ-plane
set {_circle::*} to {_circle::*} rotated around z-axis by 90 # Rotate the circle to a vertical position
show happy villager at location 1 above player's head offset by {_circle::*} in frame of player # show the particles