Package tk.airshipcraft.commonlib.world
Class RectangleArea
java.lang.Object
tk.airshipcraft.commonlib.world.AbstractYLimitedArea
tk.airshipcraft.commonlib.world.RectangleArea
- All Implemented Interfaces:
IArea
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
ConstructorsConstructorDescriptionRectangleArea
(double lowerYBound, double upperYBound, org.bukkit.Location center, double xSize, double zSize) Constructs a newRectangleArea
with specified Y boundaries, center, and size. -
Method Summary
Modifier and TypeMethodDescriptionorg.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
getWorld()
Gets the world where the rectangular area is located.double
getXSize()
Gets the size of the rectangular area along the X-axis.double
getZSize()
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
-
Constructor Details
-
RectangleArea
public RectangleArea(double lowerYBound, double upperYBound, org.bukkit.Location center, double xSize, double zSize) Constructs a newRectangleArea
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
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 interfaceIArea
- Overrides:
isInArea
in classAbstractYLimitedArea
- 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
Retrieves a collection of pseudo chunks that are within the rectangular area. Pseudo chunks are represented byPseudoChunk
and do not contain actual chunk data, but represent chunk locations within the area.- Returns:
- A collection of
PseudoChunk
objects within the area.
-