Class Rotator

java.lang.Object
redempt.redlib.multiblock.Rotator

public class Rotator extends Object
Used to rotate blocks and block sections when building or testing for the presence of a MultiBlockStructure
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rotator(int rotation, boolean mirrored)
    Constructs a new Rotator
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets a clone of this Rotator
    Gets a Rotator which will negate the operations of this Rotator
    int
     
    int
     
    double
     
    double
     
    int
    Gets the rotation, in number of 90-degree clockwise rotations
    boolean
    Gets whether this rotator mirrors over the X axis
    org.bukkit.block.data.BlockData
    rotate(org.bukkit.block.data.BlockData data)
    Rotates block data.
    org.bukkit.block.BlockFace
    rotateBlockFace(org.bukkit.block.BlockFace face)
    Rotates a BlockFace according to this Rotator
    static org.bukkit.block.BlockFace
    rotateBlockFace(org.bukkit.block.BlockFace face, int rotation)
    Rotates a BlockFace according to given values
    static org.bukkit.block.BlockFace
    rotateBlockFace(org.bukkit.block.BlockFace face, int rotation, boolean mirror)
    Rotates a BlockFace according to given values
    org.bukkit.util.Vector
    rotateVector(org.bukkit.util.Vector vector)
    Rotates a Vector according to this Rotator
    void
    setLocation(double x, double z)
    Sets the relative coordinates this Rotator will rotate
    void
    setMirrored(boolean mirrored)
    Sets whether this rotator mirrors over the X axis
    void
    setRotation(int rotation)
    Sets the rotation

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Rotator

      public Rotator(int rotation, boolean mirrored)
      Constructs a new Rotator
      Parameters:
      rotation - The number of 90-degree clockwise rotations this Rotator applies
      mirrored - Whether this Rotator should mirror over the X axis
  • Method Details

    • rotateBlockFace

      public static org.bukkit.block.BlockFace rotateBlockFace(org.bukkit.block.BlockFace face, int rotation, boolean mirror)
      Rotates a BlockFace according to given values
      Parameters:
      face - The BlockFace to rotate
      rotation - The number of clockwise rotations to apply
      mirror - Whether or not to mirror over the X axis
      Returns:
      The rotated BlockFace
    • rotateBlockFace

      public static org.bukkit.block.BlockFace rotateBlockFace(org.bukkit.block.BlockFace face, int rotation)
      Rotates a BlockFace according to given values
      Parameters:
      face - The BlockFace to rotate
      rotation - The number of clockwise rotations to apply
      Returns:
      The rotated BlockFace
    • rotate

      public org.bukkit.block.data.BlockData rotate(org.bukkit.block.data.BlockData data)
      Rotates block data. NOTE: Only works for 1.13+
      Parameters:
      data - The block data to rotate
      Returns:
      The rotated block data
    • rotateBlockFace

      public org.bukkit.block.BlockFace rotateBlockFace(org.bukkit.block.BlockFace face)
      Rotates a BlockFace according to this Rotator
      Parameters:
      face - The BlockFace to rotate
      Returns:
      The rotated BlockFace
    • rotateVector

      public org.bukkit.util.Vector rotateVector(org.bukkit.util.Vector vector)
      Rotates a Vector according to this Rotator
      Parameters:
      vector - The Vector to rotate
      Returns:
      The rotated Vector
    • setLocation

      public void setLocation(double x, double z)
      Sets the relative coordinates this Rotator will rotate
      Parameters:
      x - The relative X coordinate
      z - The relative Z coordinate
    • getRotatedBlockX

      public int getRotatedBlockX()
      Returns:
      The rotated relative block X
    • getRotatedBlockZ

      public int getRotatedBlockZ()
      Returns:
      The rotated relative block Z
    • getRotatedX

      public double getRotatedX()
      Returns:
      The rotated relative X
    • getRotatedZ

      public double getRotatedZ()
      Returns:
      The rotated relative Z
    • getInverse

      public Rotator getInverse()
      Gets a Rotator which will negate the operations of this Rotator
      Returns:
      The inverse Rotator
    • clone

      public Rotator clone()
      Gets a clone of this Rotator
      Overrides:
      clone in class Object
      Returns:
      The clone of this Rotator
    • getRotation

      public int getRotation()
      Gets the rotation, in number of 90-degree clockwise rotations
      Returns:
      The rotation
    • setRotation

      public void setRotation(int rotation)
      Sets the rotation
      Parameters:
      rotation - The rotation to set
    • setMirrored

      public void setMirrored(boolean mirrored)
      Sets whether this rotator mirrors over the X axis
      Parameters:
      mirrored - Whether this rotator mirrors over the X axis
    • isMirrored

      public boolean isMirrored()
      Gets whether this rotator mirrors over the X axis
      Returns:
      Whether this rotator mirrors over the X axis