Record Class BlockRelocability.Multiblock

java.lang.Object
java.lang.Record
net.neoforged.neoforge.common.util.BlockRelocability.Multiblock
Record Components:
requiredPositions - Set of block positions which must be moved with this block to allow moving it. This Set must include the block's own position.
All Implemented Interfaces:
BlockRelocability
Enclosing interface:
BlockRelocability

public static record BlockRelocability.Multiblock(Set<BlockPos> requiredPositions) extends Record implements BlockRelocability

BlockRelocability indicating a block may be moved if and only if some set of other block positions is being moved with it.

Large multiblocks with a "core" block may reduce the number of necessary checks by having the non-core blocks only require themselves and the core, and having the core block require all non-core positions.

  • Field Details

  • Constructor Details

    • Multiblock

      public Multiblock(Set<BlockPos> requiredPositions)
      Creates an instance of a Multiblock record class.
      Parameters:
      requiredPositions - the value for the requiredPositions record component
  • Method Details

    • isRelocatable

      public boolean isRelocatable(Set<BlockPos> relocatingPositions)
      Description copied from interface: BlockRelocability
      Returns true if the block is relocatable from a given Set of block positions, false otherwise.
      Specified by:
      isRelocatable in interface BlockRelocability
      Parameters:
      relocatingPositions - Set of positions blocks are being relocated from
      Returns:
      true if the block is relocatable from a given Set of block positions, false otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • requiredPositions

      public Set<BlockPos> requiredPositions()
      Returns the value of the requiredPositions record component.
      Returns:
      the value of the requiredPositions record component