Package ch.njol.skript.util
Class Direction
java.lang.Object
ch.njol.skript.util.Direction
- All Implemented Interfaces:
YggdrasilSerializable
,YggdrasilSerializable.YggdrasilRobustSerializable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.njol.yggdrasil.YggdrasilSerializable
YggdrasilSerializable.YggdrasilExtendedSerializable, YggdrasilSerializable.YggdrasilRobustEnum, YggdrasilSerializable.YggdrasilRobustSerializable
-
Field Summary
Modifier and TypeFieldDescriptionstatic org.bukkit.block.BlockFace
static org.bukkit.block.BlockFace
static org.bukkit.block.BlockFace
static Direction
A direction that points in the direction of the object(s) passed to the various getDirection methods.static double
Use this as pitch to force a horizontal directionstatic Noun
static Direction
A direction that doesn't point anywhere, i.e. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression<org.bukkit.Location>
combine(Expression<? extends Direction> dirs, Expression<? extends org.bukkit.Location> locs)
static @Nullable Direction
deserialize(String s)
Deprecated.boolean
boolean
excessiveField(@NonNull Fields.FieldContext field)
Called if a field was read from stream which does not exist in this class.org.bukkit.util.Vector
getDirection(org.bukkit.block.Block b)
org.bukkit.util.Vector
getDirection(org.bukkit.entity.Entity e)
org.bukkit.util.Vector
getDirection(org.bukkit.Location l)
static org.bukkit.block.BlockFace
getFacing(double yaw, double pitch)
static org.bukkit.block.BlockFace
getFacing(org.bukkit.block.Block b)
static org.bukkit.block.BlockFace
getFacing(org.bukkit.Location l, boolean horizontal)
static org.bukkit.block.BlockFace
getFacing(org.bukkit.util.Vector v, boolean horizontal)
static float
getPitch(double pitch)
org.bukkit.Location
getRelative(org.bukkit.block.Block b)
org.bukkit.Location
getRelative(org.bukkit.entity.Entity e)
org.bukkit.Location
getRelative(org.bukkit.Location l)
static org.bukkit.Location[]
getRelatives(org.bukkit.block.Block[] blocks, Direction[] directions)
static org.bukkit.Location[]
getRelatives(org.bukkit.Location[] locations, Direction[] directions)
static float
getYaw(double yaw)
int
hashCode()
boolean
incompatibleField(@NonNull Field f, @NonNull Fields.FieldContext value)
Called if a field that was read from stream is of an incompatible type to the existing field in this class.boolean
boolean
missingField(@NonNull Field field)
Called if a field was not found in the stream.static double
pitchToRadians(float pitch)
toString()
static String
toString(double[] mod)
static String
toString(double pitch, double yaw, double length)
static String
toString(org.bukkit.util.Vector dir)
static double
yawToRadians(float yaw)
-
Field Details
-
ZERO
A direction that doesn't point anywhere, i.e. equal to 'at'. -
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
-
IGNORE_PITCH
public static final double IGNORE_PITCHUse 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() -
equals
-
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
-
toString
-
toString
-
toString
-
deserialize
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 StreamCorruptedExceptionDescription 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 interfaceYggdrasilSerializable.YggdrasilRobustSerializable
- Parameters:
f
- The Java fieldvalue
- The field read from stream- Returns:
- Whether the field was handled. If false,
yggdrasil.
incompatibleField
(this, field, value) will be called. - Throws:
StreamCorruptedException
-
excessiveField
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 interfaceYggdrasilSerializable.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
Description copied from interface:YggdrasilSerializable.YggdrasilRobustSerializable
Called if a field was not found in the stream.- Specified by:
missingField
in interfaceYggdrasilSerializable.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
-