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 final BlockFace
static final BlockFace
static final BlockFace
static final Direction
A direction that points in the direction of the object(s) passed to the various getDirection methods.static final double
Use this as pitch to force a horizontal directionstatic final Noun
static final Direction
A direction that doesn't point anywhere, i.e. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
<Location> combine
(Expression<? extends Direction> dirs, Expression<? extends Location> locs) static @Nullable Direction
Deprecated.boolean
boolean
excessiveField
(@NotNull Fields.FieldContext field) Called if a field was read from stream which does not exist in this class.static BlockFace
getFacing
(double yaw, double pitch) static BlockFace
static BlockFace
static BlockFace
static float
getPitch
(double pitch) getRelative
(Block b) static Location[]
getRelatives
(Block[] blocks, Direction[] directions) static Location[]
getRelatives
(Location[] locations, Direction[] directions) static float
getYaw
(double yaw) int
hashCode()
boolean
incompatibleField
(@NotNull Field f, @NotNull 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
(@NotNull 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
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
-
BF_Y
-
BF_Z
-
m_meter
-
IGNORE_PITCH
public static final double IGNORE_PITCHUse this as pitch to force a horizontal direction- See Also:
-
-
Constructor Details
-
Direction
public Direction(double[] mod) -
Direction
public Direction() -
Direction
public Direction(double pitch, double yaw, double length) -
Direction
-
Direction
-
-
Method Details
-
getRelative
-
getRelative
-
getRelative
-
getDirection
-
getDirection
-
getDirection
-
getDirection
-
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
- Parameters:
b
-- Returns:
- The facing of the block or
BlockFace.SELF
if the block doesn't have a facing.
-
getFacing
-
getFacing
-
getFacing
-
getRelatives
-
getRelatives
-
toString
-
toString
-
toString
-
toString
-
deserialize
Deprecated. -
combine
public static Expression<Location> combine(Expression<? extends Direction> dirs, Expression<? extends Location> locs) -
incompatibleField
public boolean incompatibleField(@NotNull @NotNull Field f, @NotNull @NotNull 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 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
public boolean excessiveField(@NotNull @NotNull 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 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
-