Package cn.lunadeer.dominion.api.dtos
Class CuboidDTO
java.lang.Object
cn.lunadeer.dominion.api.dtos.CuboidDTO
Represents a cuboid (rectangular prism) in a 3D space.
This class provides methods to manipulate and query the cuboid's properties,
such as its dimensions, volume, and intersection with other cuboids.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCuboidDTO
(int[] pos1, int[] pos2) Constructs a CuboidDTO with the specified positions.CuboidDTO
(int x1, int y1, int z1, int x2, int y2, int z2) Constructs a CuboidDTO with the specified coordinates.Constructs a CuboidDTO with the same positions as the specified cuboid.Constructs a CuboidDTO with the specified world and positions.CuboidDTO
(org.bukkit.Location loc1, org.bukkit.Location loc2) Constructs a CuboidDTO with the specified world and locations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDown
(int size) Expands the cuboid downwards by the specified size.void
addEast
(int size) Expands the cuboid eastwards by the specified size.void
addNorth
(int size) Expands the cuboid northwards by the specified size.void
addSouth
(int size) Expands the cuboid southwards by the specified size.void
addUp
(int size) Expands the cuboid upwards by the specified size.void
addWest
(int size) Expands the cuboid westwards by the specified size.boolean
contain
(int x, int y, int z) Checks if this cuboid contains the specified coordinates.boolean
Checks if this cuboid contains another cuboid.boolean
containedBy
(CuboidDTO cuboid) Checks if this cuboid is contained by another cuboid.org.bukkit.Location
getLoc1
(org.bukkit.World world) Gets the first location of the cuboid in the specified world.org.bukkit.Location
getLoc2
(org.bukkit.World world) Gets the second location of the cuboid in the specified world.int[]
getPos1()
Gets the first position of the cuboid.int[]
getPos2()
Gets the second position of the cuboid.int
Gets the square area of the cuboid's base (x and z dimensions).int
Gets the volume of the cuboid.boolean
intersectWith
(CuboidDTO cuboid) Checks if this cuboid intersects with another cuboid.int
minusSquareWith
(CuboidDTO cuboid) Calculates the difference in square area between this cuboid and another cuboid.int
minusVolumeWith
(CuboidDTO cuboid) Calculates the difference in volume between this cuboid and another cuboid.void
setPos1
(int[] pos1) Sets the first position of the cuboid.void
setPos2
(int[] pos2) Sets the second position of the cuboid.int
x1()
Gets the x-coordinate of the first position.int
x2()
Gets the x-coordinate of the second position.int
xLength()
Gets the length of the cuboid along the x-axis.int
y1()
Gets the y-coordinate of the first position.int
y2()
Gets the y-coordinate of the second position.int
yLength()
Gets the length of the cuboid along the y-axis.int
z1()
Gets the z-coordinate of the first position.int
z2()
Gets the z-coordinate of the second position.int
zLength()
Gets the length of the cuboid along the z-axis.
-
Field Details
-
ZERO
A constant representing a zero-sized cuboid.
-
-
Constructor Details
-
CuboidDTO
public CuboidDTO(int[] pos1, int[] pos2) Constructs a CuboidDTO with the specified positions.- Parameters:
pos1
- the first position of the cuboidpos2
- the second position of the cuboid
-
CuboidDTO
Constructs a CuboidDTO with the same positions as the specified cuboid.- Parameters:
cuboid
- the cuboid to copy positions from
-
CuboidDTO
public CuboidDTO(int x1, int y1, int z1, int x2, int y2, int z2) Constructs a CuboidDTO with the specified coordinates.- Parameters:
x1
- the x-coordinate of the first positiony1
- the y-coordinate of the first positionz1
- the z-coordinate of the first positionx2
- the x-coordinate of the second positiony2
- the y-coordinate of the second positionz2
- the z-coordinate of the second position
-
CuboidDTO
Constructs a CuboidDTO with the specified world and positions.- Parameters:
pos1
- the first position of the cuboidpos2
- the second position of the cuboid
-
CuboidDTO
public CuboidDTO(org.bukkit.Location loc1, org.bukkit.Location loc2) Constructs a CuboidDTO with the specified world and locations.- Parameters:
loc1
- the first location of the cuboidloc2
- the second location of the cuboid
-
-
Method Details
-
getPos1
public int[] getPos1()Gets the first position of the cuboid.- Returns:
- the first position of the cuboid
-
setPos1
public void setPos1(int[] pos1) Sets the first position of the cuboid.- Parameters:
pos1
- the new first position of the cuboid
-
getPos2
public int[] getPos2()Gets the second position of the cuboid.- Returns:
- the second position of the cuboid
-
setPos2
public void setPos2(int[] pos2) Sets the second position of the cuboid.- Parameters:
pos2
- the new second position of the cuboid
-
getLoc1
public org.bukkit.Location getLoc1(org.bukkit.World world) Gets the first location of the cuboid in the specified world.- Parameters:
world
- the world in which the cuboid is located- Returns:
- the first location of the cuboid
-
getLoc2
public org.bukkit.Location getLoc2(org.bukkit.World world) Gets the second location of the cuboid in the specified world.- Parameters:
world
- the world in which the cuboid is located- Returns:
- the second location of the cuboid
-
x1
public int x1()Gets the x-coordinate of the first position.- Returns:
- the x-coordinate of the first position
-
y1
public int y1()Gets the y-coordinate of the first position.- Returns:
- the y-coordinate of the first position
-
z1
public int z1()Gets the z-coordinate of the first position.- Returns:
- the z-coordinate of the first position
-
x2
public int x2()Gets the x-coordinate of the second position.- Returns:
- the x-coordinate of the second position
-
y2
public int y2()Gets the y-coordinate of the second position.- Returns:
- the y-coordinate of the second position
-
z2
public int z2()Gets the z-coordinate of the second position.- Returns:
- the z-coordinate of the second position
-
xLength
public int xLength()Gets the length of the cuboid along the x-axis.- Returns:
- the length of the cuboid along the x-axis
-
yLength
public int yLength()Gets the length of the cuboid along the y-axis.- Returns:
- the length of the cuboid along the y-axis
-
zLength
public int zLength()Gets the length of the cuboid along the z-axis.- Returns:
- the length of the cuboid along the z-axis
-
getSquare
public int getSquare()Gets the square area of the cuboid's base (x and z dimensions).- Returns:
- the square area of the cuboid's base
-
getVolume
public int getVolume()Gets the volume of the cuboid.- Returns:
- the volume of the cuboid
-
intersectWith
Checks if this cuboid intersects with another cuboid.- Parameters:
cuboid
- the other cuboid to check for intersection- Returns:
- true if the cuboids intersect, false otherwise
-
contain
Checks if this cuboid contains another cuboid.- Parameters:
cuboid
- the other cuboid to check for containment- Returns:
- true if this cuboid contains the other cuboid, false otherwise
-
contain
public boolean contain(int x, int y, int z) Checks if this cuboid contains the specified coordinates.- Parameters:
x
- the x-coordinate to checky
- the y-coordinate to checkz
- the z-coordinate to check- Returns:
- true if this cuboid contains the specified coordinates, false otherwise
-
containedBy
Checks if this cuboid is contained by another cuboid.- Parameters:
cuboid
- the other cuboid to check for containment- Returns:
- true if this cuboid is contained by the other cuboid, false otherwise
-
minusSquareWith
Calculates the difference in square area between this cuboid and another cuboid.- Parameters:
cuboid
- the other cuboid to compare with- Returns:
- the difference in square area
-
minusVolumeWith
Calculates the difference in volume between this cuboid and another cuboid.- Parameters:
cuboid
- the other cuboid to compare with- Returns:
- the difference in volume
-
addUp
public void addUp(int size) Expands the cuboid upwards by the specified size.- Parameters:
size
- the amount to expand the cuboid upwards
-
addDown
public void addDown(int size) Expands the cuboid downwards by the specified size.- Parameters:
size
- the amount to expand the cuboid downwards
-
addNorth
public void addNorth(int size) Expands the cuboid northwards by the specified size.- Parameters:
size
- the amount to expand the cuboid northwards
-
addSouth
public void addSouth(int size) Expands the cuboid southwards by the specified size.- Parameters:
size
- the amount to expand the cuboid southwards
-
addEast
public void addEast(int size) Expands the cuboid eastwards by the specified size.- Parameters:
size
- the amount to expand the cuboid eastwards
-
addWest
public void addWest(int size) Expands the cuboid westwards by the specified size.- Parameters:
size
- the amount to expand the cuboid westwards
-