Record Class BlockInfo

java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.common.serialization.BlockInfo
Record Components:
pos - The absolute or relative position of the block as a Vector. May be null when position is not relevant (e.g., templates).
block - The underlying block representation:
  • CustomBlock for custom blocks
  • BlockData for vanilla blocks
Must not be null.
states - A JSON object representing serialized block state properties (e.g., facing, waterlogged). May be null if no states exist.
properties - A JSON object representing custom block entity data specific to CustomBlock implementations. May be null.
nbt - A JSON object representing serialized vanilla tile entity (NBT-like) data such as inventories or sign text. May be null.

public record BlockInfo(@Nullable org.bukkit.util.Vector pos, Object block, @Nullable com.fasterxml.jackson.databind.node.ObjectNode states, @Nullable com.fasterxml.jackson.databind.node.ObjectNode properties, @Nullable com.fasterxml.jackson.databind.node.ObjectNode nbt) extends Record
Represents a fully self-contained snapshot of a block, including its position, type, visual states, custom properties, and optional tile/NBT data.

This record is used as a unified data structure across:

  • Structure serialization and placement
  • Procedural world generation
  • Block state persistence and transformation

A BlockInfo may represent either:

  • A CustomBlock (AbyssalLib-defined block)
  • A vanilla BlockData instance

Each instance may optionally include:

  • Visual state data (states)
  • Custom block entity properties (properties)
  • Vanilla tile/NBT data (nbt)
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockInfo(@Nullable org.bukkit.util.Vector pos, Object block, @Nullable com.fasterxml.jackson.databind.node.ObjectNode states, @Nullable com.fasterxml.jackson.databind.node.ObjectNode properties, @Nullable com.fasterxml.jackson.databind.node.ObjectNode nbt)
    Creates an instance of a BlockInfo record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the block record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the string identifier of the underlying block.
    final int
    Returns a hash code value for this object.
    @Nullable com.fasterxml.jackson.databind.node.ObjectNode
    nbt()
    Returns the value of the nbt record component.
    @Nullable org.bukkit.util.Vector
    pos()
    Returns the value of the pos record component.
    @Nullable com.fasterxml.jackson.databind.node.ObjectNode
    Returns the value of the properties record component.
    static BlockInfo
    resolve(org.bukkit.block.Block block)
    Creates a BlockInfo snapshot from a live Bukkit Block.
    @Nullable com.fasterxml.jackson.databind.node.ObjectNode
    Returns the value of the states record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • BlockInfo

      public BlockInfo(@Nullable @Nullable org.bukkit.util.Vector pos, Object block, @Nullable @Nullable com.fasterxml.jackson.databind.node.ObjectNode states, @Nullable @Nullable com.fasterxml.jackson.databind.node.ObjectNode properties, @Nullable @Nullable com.fasterxml.jackson.databind.node.ObjectNode nbt)
      Creates an instance of a BlockInfo record class.
      Parameters:
      pos - the value for the pos record component
      block - the value for the block record component
      states - the value for the states record component
      properties - the value for the properties record component
      nbt - the value for the nbt record component
  • Method Details

    • getAsString

      public String getAsString()
      Returns the string identifier of the underlying block.

      The identifier format depends on the block type:

      • CustomBlock: uses its registered ID (e.g., abyssal:my_block)
      • BlockData: uses a vanilla Minecraft ID (e.g., minecraft:stone)

      If the block type is unknown, this method defaults to minecraft:air.

      Returns:
      The string identifier representing this block.
    • resolve

      public static BlockInfo resolve(org.bukkit.block.Block block)
      Creates a BlockInfo snapshot from a live Bukkit Block.

      This method extracts and serializes:

      • Block position
      • Block type (custom or vanilla)
      • Block state properties
      • Custom block entity data (if applicable)
      • Vanilla tile/NBT data

      Resolution priority:

      1. If a CustomBlock exists at the location, it is used
      2. Otherwise, the block is treated as vanilla BlockData
      Parameters:
      block - The Bukkit Block to snapshot. Must not be null.
      Returns:
      A fully populated BlockInfo representing the current block state.
    • 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.
    • pos

      @Nullable public @Nullable org.bukkit.util.Vector pos()
      Returns the value of the pos record component.
      Returns:
      the value of the pos record component
    • block

      public Object block()
      Returns the value of the block record component.
      Returns:
      the value of the block record component
    • states

      @Nullable public @Nullable com.fasterxml.jackson.databind.node.ObjectNode states()
      Returns the value of the states record component.
      Returns:
      the value of the states record component
    • properties

      @Nullable public @Nullable com.fasterxml.jackson.databind.node.ObjectNode properties()
      Returns the value of the properties record component.
      Returns:
      the value of the properties record component
    • nbt

      @Nullable public @Nullable com.fasterxml.jackson.databind.node.ObjectNode nbt()
      Returns the value of the nbt record component.
      Returns:
      the value of the nbt record component