Record Class BlockStateSnapshot

java.lang.Object
java.lang.Record
nl.pim16aap2.lightkeeper.framework.BlockStateSnapshot
Record Components:
materialKey - Canonical namespaced material key.
blockData - The full block-data string the server reported (every state property included).
properties - All state properties, in the server's rendering order.

public record BlockStateSnapshot(String materialKey, String blockData, Map<String,String> properties) extends Record
Frozen snapshot of a block's full state at the moment it was read.
  • Constructor Details

    • BlockStateSnapshot

      public BlockStateSnapshot(String materialKey, String blockData, Map<String,String> properties)
      Validates the fields.
  • Method Details

    • property

      public @Nullable String property(String name)
      Gets a single state property.
      Parameters:
      name - The property name, e.g. powered.
      Returns:
      The property value, or null when the block has no such property.
    • matches

      public boolean matches(BlockSpec spec)
      Checks whether this state matches a spec: the material must be equal and every property the spec names must have the spec's value. Properties the spec does not name are ignored — partial matching by design.
      Parameters:
      spec - The expected spec.
      Returns:
      true when this state matches.
    • 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.
    • materialKey

      public String materialKey()
      Returns the value of the materialKey record component.
      Returns:
      the value of the materialKey record component
    • blockData

      public String blockData()
      Returns the value of the blockData record component.
      Returns:
      the value of the blockData record component
    • properties

      public Map<String,String> properties()
      Returns the value of the properties record component.
      Returns:
      the value of the properties record component