Class RectangleArea

java.lang.Object
tk.airshipcraft.commonlib.world.AbstractYLimitedArea
tk.airshipcraft.commonlib.world.RectangleArea
All Implemented Interfaces:
IArea

public class RectangleArea extends AbstractYLimitedArea
Represents a rectangular area in a Minecraft world with Y-level boundaries. The area is defined by a center Location, a size along the X-axis (xSize), and a size along the Z-axis (zSize). This class can be used to check if specific locations or chunks fall within the area.
Since:
2023-04-01
Version:
1.0.0
Author:
notzune
  • Constructor Summary

    Constructors
    Constructor
    Description
    RectangleArea(double lowerYBound, double upperYBound, org.bukkit.Location center, double xSize, double zSize)
    Constructs a new RectangleArea with specified Y boundaries, center, and size.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.Location
    Gets the center location of the rectangular area.
    Collection<org.bukkit.Chunk>
    Retrieves a collection of chunks that are within the rectangular area.
    Retrieves a collection of pseudo chunks that are within the rectangular area.
    org.bukkit.World
    Gets the world where the rectangular area is located.
    double
    Gets the size of the rectangular area along the X-axis.
    double
    Gets the size of the rectangular area along the Z-axis.
    boolean
    isInArea(org.bukkit.Location loc)
    Checks if a location is within the rectangular area.

    Methods inherited from class tk.airshipcraft.commonlib.world.AbstractYLimitedArea

    getLowerYBound, getUpperYBound

    Methods inherited from class java.lang.Object

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

    • RectangleArea

      public RectangleArea(double lowerYBound, double upperYBound, org.bukkit.Location center, double xSize, double zSize)
      Constructs a new RectangleArea with specified Y boundaries, center, and size.
      Parameters:
      lowerYBound - The lower Y boundary of the area.
      upperYBound - The upper Y boundary of the area.
      center - The center location of the rectangular area.
      xSize - Half of the size of the rectangle along the X-axis.
      zSize - Half of the size of the rectangle along the Z-axis.
  • Method Details

    • getChunks

      public Collection<org.bukkit.Chunk> getChunks()
      Retrieves a collection of chunks that are within the rectangular area.
      Returns:
      A collection of Chunk objects within the area.
    • isInArea

      public boolean isInArea(org.bukkit.Location loc)
      Checks if a location is within the rectangular area.
      Specified by:
      isInArea in interface IArea
      Overrides:
      isInArea in class AbstractYLimitedArea
      Parameters:
      loc - The location to check.
      Returns:
      True if the location is within the area, false otherwise.
    • getCenter

      public org.bukkit.Location getCenter()
      Gets the center location of the rectangular area.
      Returns:
      The center Location of the area.
    • getWorld

      public org.bukkit.World getWorld()
      Gets the world where the rectangular area is located.
      Returns:
      The World object representing the world of the area.
    • getXSize

      public double getXSize()
      Gets the size of the rectangular area along the X-axis.
      Returns:
      Half the size of the area along the X-axis.
    • getZSize

      public double getZSize()
      Gets the size of the rectangular area along the Z-axis.
      Returns:
      Half the size of the area along the Z-axis.
    • getPseudoChunks

      public Collection<PseudoChunk> getPseudoChunks()
      Retrieves a collection of pseudo chunks that are within the rectangular area. Pseudo chunks are represented by PseudoChunk and do not contain actual chunk data, but represent chunk locations within the area.
      Returns:
      A collection of PseudoChunk objects within the area.