Class Direction

java.lang.Object
ch.njol.skript.util.Direction
All Implemented Interfaces:
YggdrasilSerializable, YggdrasilSerializable.YggdrasilRobustSerializable

public class Direction extends Object implements YggdrasilSerializable.YggdrasilRobustSerializable
  • Field Details

    • ZERO

      public static final Direction ZERO
      A direction that doesn't point anywhere, i.e. equal to 'at'.
    • IDENTITY

      public static final Direction IDENTITY
      A direction that points in the direction of the object(s) passed to the various getDirection methods.
    • BF_X

      public static final org.bukkit.block.BlockFace BF_X
    • BF_Y

      public static final org.bukkit.block.BlockFace BF_Y
    • BF_Z

      public static final org.bukkit.block.BlockFace BF_Z
    • m_meter

      public static final Noun m_meter
    • IGNORE_PITCH

      public static final double IGNORE_PITCH
      Use this as pitch to force a horizontal direction
      See Also:
      Constant Field Values
  • Constructor Details

    • Direction

      public Direction(double[] mod)
    • Direction

      public Direction()
    • Direction

      public Direction(double pitch, double yaw, double length)
    • Direction

      public Direction(org.bukkit.block.BlockFace f, double length)
    • Direction

      public Direction(org.bukkit.util.Vector v)
  • Method Details

    • getRelative

      public org.bukkit.Location getRelative(org.bukkit.Location l)
    • getRelative

      public org.bukkit.Location getRelative(org.bukkit.entity.Entity e)
    • getRelative

      public org.bukkit.Location getRelative(org.bukkit.block.Block b)
    • getDirection

      public org.bukkit.util.Vector getDirection(org.bukkit.Location l)
    • getDirection

      public org.bukkit.util.Vector getDirection(org.bukkit.entity.Entity e)
    • getDirection

      public org.bukkit.util.Vector getDirection(org.bukkit.block.Block b)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • isRelative

      public boolean isRelative()
      Returns:
      Whether this Direction rotates the direction of a given object or only translates it.
    • pitchToRadians

      public static double pitchToRadians(float pitch)
      Parameters:
      pitch - Notch-pitch
      Returns:
      Mathematical pitch oriented from x/z to y axis (with the origin in the x/z plane)
    • getPitch

      public static float getPitch(double pitch)
      Parameters:
      pitch - Mathematical pitch oriented from x/z to y axis (with the origin in the x/z plane)
      Returns:
      Notch-pitch
    • yawToRadians

      public static double yawToRadians(float yaw)
      Parameters:
      yaw - Notch-yaw
      Returns:
      Mathematical yaw oriented from x to z axis (with the origin at the x axis)
    • getYaw

      public static float getYaw(double yaw)
      Parameters:
      yaw - Mathematical yaw oriented from x to z axis (with the origin at the x axis)
      Returns:
      Notch-yaw
    • getFacing

      public static org.bukkit.block.BlockFace getFacing(org.bukkit.block.Block b)
      Parameters:
      b -
      Returns:
      The facing of the block or BlockFace.SELF if the block doesn't have a facing.
    • getFacing

      public static org.bukkit.block.BlockFace getFacing(double yaw, double pitch)
    • getFacing

      public static org.bukkit.block.BlockFace getFacing(org.bukkit.Location l, boolean horizontal)
    • getFacing

      public static org.bukkit.block.BlockFace getFacing(org.bukkit.util.Vector v, boolean horizontal)
    • getRelatives

      public static org.bukkit.Location[] getRelatives(org.bukkit.block.Block[] blocks, Direction[] directions)
    • getRelatives

      public static org.bukkit.Location[] getRelatives(org.bukkit.Location[] locations, Direction[] directions)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public static String toString(double pitch, double yaw, double length)
    • toString

      public static String toString(double[] mod)
    • toString

      public static String toString(org.bukkit.util.Vector dir)
    • deserialize

      @Deprecated public static @Nullable Direction deserialize(String s)
      Deprecated.
    • combine

      public static Expression<org.bukkit.Location> combine(Expression<? extends Direction> dirs, Expression<? extends org.bukkit.Location> locs)
    • incompatibleField

      public boolean incompatibleField(@NonNull Field f, @NonNull Fields.FieldContext value) throws StreamCorruptedException
      Description copied from interface: YggdrasilSerializable.YggdrasilRobustSerializable
      Called if a field that was read from stream is of an incompatible type to the existing field in this class.
      Specified by:
      incompatibleField in interface YggdrasilSerializable.YggdrasilRobustSerializable
      Parameters:
      f - The Java field
      value - The field read from stream
      Returns:
      Whether the field was handled. If false, yggdrasil.incompatibleField(this, field, value) will be called.
      Throws:
      StreamCorruptedException
    • excessiveField

      public boolean excessiveField(@NonNull Fields.FieldContext field) throws StreamCorruptedException
      Description copied from interface: YggdrasilSerializable.YggdrasilRobustSerializable
      Called if a field was read from stream which does not exist in this class.
      Specified by:
      excessiveField in interface YggdrasilSerializable.YggdrasilRobustSerializable
      Parameters:
      field - The field read from stream
      Returns:
      Whether the field was handled. If false, yggdrasil.excessiveField(this, field) will be called.
      Throws:
      StreamCorruptedException
    • missingField

      public boolean missingField(@NonNull Field field) throws StreamCorruptedException
      Description copied from interface: YggdrasilSerializable.YggdrasilRobustSerializable
      Called if a field was not found in the stream.
      Specified by:
      missingField in interface YggdrasilSerializable.YggdrasilRobustSerializable
      Parameters:
      field - The field that did not occur in the stream
      Returns:
      Whether the field was handled (e.g. true if the default value is fine). If false, yggdrasil.missingField(this, field) will be called.
      Throws:
      StreamCorruptedException