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 org.bukkit.block.BlockFacestatic org.bukkit.block.BlockFacestatic org.bukkit.block.BlockFacestatic DirectionA direction that points in the direction of the object(s) passed to the various getDirection methods.static doubleUse this as pitch to force a horizontal directionstatic Nounstatic DirectionA direction that doesn't point anywhere, i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Expression<org.bukkit.Location>combine(Expression<? extends Direction> dirs, Expression<? extends org.bukkit.Location> locs)static @Nullable Directiondeserialize(String s)Deprecated.booleanbooleanexcessiveField(@NonNull Fields.FieldContext field)Called if a field was read from stream which does not exist in this class.org.bukkit.util.VectorgetDirection(org.bukkit.block.Block b)org.bukkit.util.VectorgetDirection(org.bukkit.entity.Entity e)org.bukkit.util.VectorgetDirection(org.bukkit.Location l)static org.bukkit.block.BlockFacegetFacing(double yaw, double pitch)static org.bukkit.block.BlockFacegetFacing(org.bukkit.block.Block b)static org.bukkit.block.BlockFacegetFacing(org.bukkit.Location l, boolean horizontal)static org.bukkit.block.BlockFacegetFacing(org.bukkit.util.Vector v, boolean horizontal)static floatgetPitch(double pitch)org.bukkit.LocationgetRelative(org.bukkit.block.Block b)org.bukkit.LocationgetRelative(org.bukkit.entity.Entity e)org.bukkit.LocationgetRelative(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 floatgetYaw(double yaw)inthashCode()booleanincompatibleField(@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.booleanbooleanmissingField(@NonNull 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 StringtoString(org.bukkit.util.Vector dir)static 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
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.SELFif 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.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
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
-