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
FieldsModifier and TypeFieldDescriptionstatic final BlockFacestatic final BlockFacestatic final BlockFacestatic final DirectionA direction that points in the direction of the object(s) passed to the various getDirection methods.static final doubleUse this as pitch to force a horizontal directionstatic final Nounstatic final DirectionA direction that doesn't point anywhere, i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Expression<Location> combine(Expression<? extends Direction> dirs, Expression<? extends Location> locs) static @Nullable DirectionDeprecated.booleanbooleanexcessiveField(@NotNull Fields.FieldContext field) Called if a field was read from stream which does not exist in this class.static BlockFacegetFacing(double yaw, double pitch) static BlockFacestatic BlockFacestatic BlockFacestatic floatgetPitch(double pitch) getRelative(Block b) static Location[]getRelatives(Block[] blocks, Direction[] directions) static Location[]getRelatives(Location[] locations, Direction[] directions) static floatgetYaw(double yaw) inthashCode()booleanincompatibleField(@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.booleanbooleanmissingField(@NotNull Field field) Called if a field was not found in the stream.static doublepitchToRadians(float pitch) toString()static StringtoString(double[] mod) static StringtoString(double pitch, double yaw, double length) static Stringstatic doubleyawToRadians(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.SELFif 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.YggdrasilRobustSerializableCalled if a field that was read from stream is of an incompatible type to the existing field in this class.- Specified by:
incompatibleFieldin 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.YggdrasilRobustSerializableCalled if a field was read from stream which does not exist in this class.- Specified by:
excessiveFieldin 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.YggdrasilRobustSerializableCalled if a field was not found in the stream.- Specified by:
missingFieldin 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
-