Record Class MaskedCuboid

java.lang.Object
java.lang.Record
codechicken.microblock.util.MaskedCuboid

public record MaskedCuboid(codechicken.lib.vec.Cuboid6 box, int sideMask) extends Record
A cuboid and side mask pair.

Cuboids should be treated as immutable and not modified.

Masks are, if bit set, side is important.

MaskedCuboids should be created with of(Cuboid6, int) to receive automatic interning and caching. Making sure these are interned is important, as these are stored inside caches as keys, and may be long-lived. Ensuring that duplicates aren't saved is important to keep memory usage down. Ideally we should cache sets of cuboids as well, but that's a later issue.

Created by covers1624 on 20/10/22.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MaskedCuboid(codechicken.lib.vec.Cuboid6 box, int sideMask)
    Creates an instance of a MaskedCuboid record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    codechicken.lib.vec.Cuboid6
    box()
    Returns the value of the box record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
     
    of(codechicken.lib.vec.Cuboid6 box, int sideMask)
     
    int
    Returns the value of the sideMask record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MaskedCuboid

      public MaskedCuboid(codechicken.lib.vec.Cuboid6 box, int sideMask)
      Creates an instance of a MaskedCuboid record class.
      Parameters:
      box - the value for the box record component
      sideMask - the value for the sideMask record component
  • Method Details

    • intern

      public static MaskedCuboid intern(MaskedCuboid cuboid)
    • of

      public static MaskedCuboid of(codechicken.lib.vec.Cuboid6 box, int sideMask)
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • box

      public codechicken.lib.vec.Cuboid6 box()
      Returns the value of the box record component.
      Returns:
      the value of the box record component
    • sideMask

      public int sideMask()
      Returns the value of the sideMask record component.
      Returns:
      the value of the sideMask record component