记录类 CuboidArea

java.lang.Object
java.lang.Record
io.github.lijinhong11.mittellib.math.CuboidArea
记录组件:
pos1 - the point 1
pos2 - the point 2

public record CuboidArea(BlockPos pos1, BlockPos pos2) extends Record
Represents a cuboid (rectangular) area defined by two block positions.
  • 构造器概要

    构造器
    构造器
    说明
    创建 CuboidArea 记录类的实例。
  • 方法概要

    修饰符和类型
    方法
    说明
    Converts this cuboid area to a list of all block positions it contains.
    boolean
    Checks if a block position is contained within this cuboid area.
    static CuboidArea
    Creates a CuboidArea from two Bukkit Locations.
    final boolean
    指示某个其他对象是否“等于”此对象。
    expand(int x)
    Expands this cuboid area by the specified amount in all directions.
    expand(int x, int y)
    Expands this cuboid area by the specified amounts in X and Y directions.
    expand(int x, int y, int z)
    Expands this cuboid area by the specified amounts in all directions.
    void
    Performs an action for each block position in this cuboid area.
    Gets the center location of this cuboid area in the specified world.
    Gets the maximum corner position of this cuboid area.
    Gets the minimum corner position of this cuboid area.
    final int
    返回此对象的哈希代码值。
    返回 pos1 记录组件的值。
    返回 pos2 记录组件的值。
    int
    Gets the size of this cuboid area in the X direction.
    int
    Gets the size of this cuboid area in the Y direction.
    int
    Gets the size of this cuboid area in the Z direction.
    @NotNull String
    返回此记录类的字符串表示形式。
    int
    Gets the total number of blocks in this cuboid area.

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 构造器详细资料

    • CuboidArea

      public CuboidArea(BlockPos pos1, BlockPos pos2)
      创建 CuboidArea 记录类的实例。
      参数:
      pos1 - pos1 记录组件的值
      pos2 - pos2 记录组件的值
  • 方法详细资料

    • createFromLocation

      public static CuboidArea createFromLocation(Location loc1, Location loc2)
      Creates a CuboidArea from two Bukkit Locations.
      参数:
      loc1 - the first location
      loc2 - the second location
      返回:
      a new CuboidArea
    • getMin

      public BlockPos getMin()
      Gets the minimum corner position of this cuboid area.
      返回:
      the minimum BlockPos
    • getMax

      public BlockPos getMax()
      Gets the maximum corner position of this cuboid area.
      返回:
      the maximum BlockPos
    • getCenterLocation

      public Location getCenterLocation(World world)
      Gets the center location of this cuboid area in the specified world.
      参数:
      world - the world for the location
      返回:
      the center location
    • expand

      public CuboidArea expand(int x)
      Expands this cuboid area by the specified amount in all directions.
      参数:
      x - the amount to expand in X direction
      返回:
      a new expanded CuboidArea
    • expand

      public CuboidArea expand(int x, int y)
      Expands this cuboid area by the specified amounts in X and Y directions.
      参数:
      x - the amount to expand in X direction
      y - the amount to expand in Y direction
      返回:
      a new expanded CuboidArea
    • expand

      public CuboidArea expand(int x, int y, int z)
      Expands this cuboid area by the specified amounts in all directions.
      参数:
      x - the amount to expand in X direction
      y - the amount to expand in Y direction
      z - the amount to expand in Z direction
      返回:
      a new expanded CuboidArea
    • contains

      public boolean contains(BlockPos pos)
      Checks if a block position is contained within this cuboid area.
      参数:
      pos - the position to check
      返回:
      true if the position is within the area, false otherwise
    • sizeX

      public int sizeX()
      Gets the size of this cuboid area in the X direction.
      返回:
      the X size (in blocks)
    • sizeY

      public int sizeY()
      Gets the size of this cuboid area in the Y direction.
      返回:
      the Y size (in blocks)
    • sizeZ

      public int sizeZ()
      Gets the size of this cuboid area in the Z direction.
      返回:
      the Z size (in blocks)
    • volume

      public int volume()
      Gets the total number of blocks in this cuboid area.
      返回:
      the total number of blocks
    • forEach

      public void forEach(Consumer<BlockPos> action)
      Performs an action for each block position in this cuboid area.
      参数:
      action - the action to perform for each position
    • asPosList

      public List<BlockPos> asPosList()
      Converts this cuboid area to a list of all block positions it contains.
      返回:
      a list of all BlockPos in this area
    • toString

      @NotNull public @NotNull String toString()
      返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。
      指定者:
      toString 在类中 Record
      返回:
      此对象的字符串表示形式
    • hashCode

      public final int hashCode()
      返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。
      指定者:
      hashCode 在类中 Record
      返回:
      此对象的哈希代码值
    • equals

      public final boolean equals(Object o)
      指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录类中的所有组件都使用 Objects::equals(Object,Object) 进行比较。
      指定者:
      equals 在类中 Record
      参数:
      o - 要与之进行比较的对象
      返回:
      如果此对象与 o 参数相同,则为 true;否则为 false
    • pos1

      public BlockPos pos1()
      返回 pos1 记录组件的值。
      返回:
      pos1 记录组件的值
    • pos2

      public BlockPos pos2()
      返回 pos2 记录组件的值。
      返回:
      pos2 记录组件的值