Class SpheroidRegion

java.lang.Object
redempt.redlib.region.Region
redempt.redlib.region.SpheroidRegion
All Implemented Interfaces:
Cloneable

public class SpheroidRegion extends Region
Represents a spheroid region in a world
  • Constructor Details

    • SpheroidRegion

      public SpheroidRegion(org.bukkit.Location start, org.bukkit.Location end)
      Creates a SpheroidRegion from two corners, using their midpoint as the center and their distance in each direction as the radius on each axis
      Parameters:
      start - The first corner
      end - The second corner
      Throws:
      IllegalArgumentException - if the Locations are not in the same world
    • SpheroidRegion

      public SpheroidRegion(org.bukkit.Location center, double xRad, double yRad, double zRad)
      Creates a SpheroidRegion from a center and a radius in each direction
      Parameters:
      center - The center
      xRad - The radius on the X axis
      yRad - The radius on the Y axis
      zRad - The radius on the Z axis
    • SpheroidRegion

      public SpheroidRegion(org.bukkit.Location center, double radius)
      Creates a SpheroidRegion from a center and a radius
      Parameters:
      center - The center
      radius - The radius
  • Method Details

    • getVolume

      public double getVolume()
      Specified by:
      getVolume in class Region
      Returns:
      The volume of this SpheroidRegion
    • getBlockVolume

      public int getBlockVolume()
      Specified by:
      getBlockVolume in class Region
      Returns:
      The *approximate* block volume of this SpheroidRegion
    • expand

      public SpheroidRegion expand(double posX, double negX, double posY, double negY, double posZ, double negZ)
      Expands this SpheroidRegion in all directions
      Specified by:
      expand in class Region
      Parameters:
      posX - The amount to increase in the positive X direction
      negX - The amount to increase in the negative X direction
      posY - The amount to increase in the positive Y direction
      negY - The amount to increase in the negative Y direction
      posZ - The amount to increase in the positive Z direction
      negZ - The amount to increase in the negative Z direction
      Returns:
      Itself
    • expand

      public SpheroidRegion expand(org.bukkit.block.BlockFace face, double amount)
      Expands this SpheroidRegion in a specific direction
      Specified by:
      expand in class Region
      Parameters:
      face - The BlockFace representing the direction to expand in
      amount - The amount to expand
      Returns:
      Itself
    • expand

      public SpheroidRegion expand(double amount)
      Expands this SpheroidRegion in all directions
      Parameters:
      amount - The amount to expand by in all directions
      Returns:
      Itself
    • move

      public SpheroidRegion move(org.bukkit.util.Vector vec)
      Moves this SpheroidRegion according to a Vector
      Specified by:
      move in class Region
      Parameters:
      vec - The vector representing the direction and amount to move
      Returns:
      Itself
    • move

      public SpheroidRegion move(double x, double y, double z)
      Moves this SpheroidRegion
      Specified by:
      move in class Region
      Parameters:
      x - The amount to move this SpheroidRegion on the X axis
      y - The amount to move this SpheroidRegion on the Y axis
      z - The amount to move this SpheroidRegion on the Z axis
      Returns:
      Itself
    • contains

      public boolean contains(org.bukkit.Location loc)
      Checks if this SpheroidRegion contains a given point
      Specified by:
      contains in class Region
      Parameters:
      loc - The location to check
      Returns:
      Whether this SpheroidRegion contains the given Location
    • isSphere

      public boolean isSphere()
      Returns:
      True if the radius in all directions of this SpheroidRegion are the same
    • clone

      public SpheroidRegion clone()
      Specified by:
      clone in class Region
      Returns:
      A clone of this SpheroidRegion
    • rotate

      public SpheroidRegion rotate(org.bukkit.Location center, int rotations)
      Rotates this SpheroidRegion
      Specified by:
      rotate in class Region
      Parameters:
      center - The center of rotation
      rotations - The number of clockwise rotations
      Returns:
      Itself
    • setWorld

      public SpheroidRegion setWorld(org.bukkit.World world)
      Sets the world of this SpheroidRegion
      Specified by:
      setWorld in class Region
      Parameters:
      world - The World
      Returns:
      Itself
    • stream

      public Stream<org.bukkit.block.Block> stream()
      Description copied from class: Region
      Streams all Blocks inside this Region
      Specified by:
      stream in class Region
      Returns:
      A stream of all Blocks contained by this SpheroidRegion
    • toCuboid

      public CuboidRegion toCuboid()
      Overrides:
      toCuboid in class Region
      Returns:
      A cuboid representation of this SpheroidRegion using the extreme corners
    • getXRadius

      public double getXRadius()
      Returns:
      The radius of the spheroid on the X axis
    • getYRadius

      public double getYRadius()
      Returns:
      The radius of the spheroid on the Y axis
    • getZRadius

      public double getZRadius()
      Returns:
      The radius of the spheroid on the Z axis
    • setXRadius

      public SpheroidRegion setXRadius(double xRad)
      Sets the radius of the spheroid on the X axis
      Parameters:
      xRad - The radius on the X axis
      Returns:
      Itself
    • setYRadius

      public SpheroidRegion setYRadius(double yRad)
      Sets the radius of the spheroid on the Y axis
      Parameters:
      yRad - The radius on the Y axis
      Returns:
      Itself
    • setZRadius

      public SpheroidRegion setZRadius(double zRad)
      Sets the radius of the spheroid on the Z axis
      Parameters:
      zRad - The radius on the Z axis
      Returns:
      Itself
    • getStart

      public org.bukkit.Location getStart()
      Specified by:
      getStart in class Region
      Returns:
      The least extreme corner of this SpheroidRegion representing the minimum X, Y, and Z coordinates
    • getEnd

      public org.bukkit.Location getEnd()
      Specified by:
      getEnd in class Region
      Returns:
      The move extreme corner of this SpheroidRegion representing the maximum X, Y, and Z coordinates
    • getWorld

      public org.bukkit.World getWorld()
      Overrides:
      getWorld in class Region
      Returns:
      The World this SpheroidRegion is in
    • getCenter

      public org.bukkit.Location getCenter()
      Overrides:
      getCenter in class Region
      Returns:
      The center of this SpheroidRegion
    • getSurfacePoint

      public org.bukkit.Location getSurfacePoint(org.bukkit.util.Vector v)
      Gets a point on the surface of this SpheroidRegion in the given direction
      Parameters:
      v - The direction to get the point in
      Returns:
      The point on the surface of this SpheroidRegion
    • getSurface

      public Set<org.bukkit.block.Block> getSurface()
      Returns:
      A Set containing all of the blocks on the surface of this SpheroidRegion
    • surfaceContains

      public boolean surfaceContains(org.bukkit.block.Block block)
      Determines whether a block is on the surface of this SpheroidRegion
      Parameters:
      block - The block to check
      Returns:
      Whether the block is on the surface of this SpheroidRegion
    • equals

      public boolean equals(Object object)
      Determines whether this SpheroidRegion equals another object based on its getCenter(), getXRadius(), getYRadius(), and getZRadius()
      Overrides:
      equals in class Region
      Parameters:
      object - The object to compare to
      Returns:
      Whether the object is a SpheroidRegion and has the same center and radii
    • hashCode

      public int hashCode()
      Generates a hash code for this SpheroidRegion
      Overrides:
      hashCode in class Region
      Returns:
      The hash code
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      A String representation of this SpheroidRegion which can later be deserialized with fromString(String)
    • fromString

      public static SpheroidRegion fromString(String string)
      Deserializes a SpheroidRegion serialized with toString()
      Parameters:
      string - The serialized SpheroidRegion String
      Returns:
      The deserialized SpheroidRegion