Class Cuboid

java.lang.Object
net.pottercraft.ollivanders2.common.Cuboid

public class Cuboid extends Object
Represents a rectangular cuboid area in a Minecraft world.

Defines a 3D region using two opposite corner coordinates (x1, y1, z1) and (x2, y2, z2). Coordinates are inclusive and work regardless of which corner has higher or lower values.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Cuboid(@NotNull String world, int[] area)
    Constructor that creates a cuboid from coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isInside(String world, int x, int y, int z)
    Checks if a point with the given coordinates is inside this cuboid.
    boolean
    isInside(@NotNull org.bukkit.Location location)
    Checks if a location is inside this cuboid.
    static @org.jetbrains.annotations.Nullable int[]
    parseArea(@NotNull String areaString)
    Parses a string representation of cuboid coordinates into an integer array.

    Methods inherited from class java.lang.Object

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

    • Cuboid

      public Cuboid(@NotNull @NotNull String world, int[] area)
      Constructor that creates a cuboid from coordinates.

      If the area array length is not exactly 6, all coordinates remain at their default value of 0.

      Parameters:
      world - the name of the world this cuboid is in
      area - an array of 6 integers in format: [x1, y1, z1, x2, y2, z2] representing two opposite corners
  • Method Details

    • isInside

      public boolean isInside(@NotNull @NotNull org.bukkit.Location location)
      Checks if a location is inside this cuboid.
      Parameters:
      location - the location to check
      Returns:
      true if the location is inside this cuboid, false otherwise
    • isInside

      public boolean isInside(String world, int x, int y, int z)
      Checks if a point with the given coordinates is inside this cuboid.
      Parameters:
      world - the name of the world this point is in
      x - the x-coordinate
      y - the y-coordinate
      z - the z-coordinate
      Returns:
      true if the point is inside this cuboid, false otherwise
    • parseArea

      @Nullable public static @org.jetbrains.annotations.Nullable int[] parseArea(@NotNull @NotNull String areaString)
      Parses a string representation of cuboid coordinates into an integer array.

      Expected format: space-separated integers for two opposite corners in the order x1 y1 z1 x2 y2 z2. All six values must be valid integers.

      Parameters:
      areaString - a space-separated string of six integer coordinates (e.g., "0 0 0 100 100 100")
      Returns:
      an int array [x1, y1, z1, x2, y2, z2] or null if parsing failed