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 aVector. May benullwhen position is not relevant (e.g., templates).block- The underlying block representation:CustomBlockfor custom blocksBlockDatafor vanilla blocks
null.states- A JSON object representing serialized block state properties (e.g., facing, waterlogged). May benullif no states exist.properties- A JSON object representing custom block entity data specific toCustomBlockimplementations. May benull.nbt- A JSON object representing serialized vanilla tile entity (NBT-like) data such as inventories or sign text. May benull.
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
BlockDatainstance
Each instance may optionally include:
- Visual state data (
states) - Custom block entity properties (
properties) - Vanilla tile/NBT data (
nbt)
-
Constructor Summary
ConstructorsConstructorDescriptionBlockInfo(@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 aBlockInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionblock()Returns the value of theblockrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the string identifier of the underlying block.final inthashCode()Returns a hash code value for this object.@Nullable com.fasterxml.jackson.databind.node.ObjectNodenbt()Returns the value of thenbtrecord component.@Nullable org.bukkit.util.Vectorpos()Returns the value of theposrecord component.@Nullable com.fasterxml.jackson.databind.node.ObjectNodeReturns the value of thepropertiesrecord component.static BlockInforesolve(org.bukkit.block.Block block) Creates aBlockInfosnapshot from a live BukkitBlock.@Nullable com.fasterxml.jackson.databind.node.ObjectNodestates()Returns the value of thestatesrecord component.final StringtoString()Returns a string representation of this record class.
-
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 aBlockInforecord class.- Parameters:
pos- the value for theposrecord componentblock- the value for theblockrecord componentstates- the value for thestatesrecord componentproperties- the value for thepropertiesrecord componentnbt- the value for thenbtrecord component
-
-
Method Details
-
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
Creates aBlockInfosnapshot from a live BukkitBlock.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:
- If a
CustomBlockexists at the location, it is used - Otherwise, the block is treated as vanilla
BlockData
- Parameters:
block- The BukkitBlockto snapshot. Must not benull.- Returns:
- A fully populated
BlockInforepresenting the current block state.
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
pos
-
block
-
states
-
properties
@Nullable public @Nullable com.fasterxml.jackson.databind.node.ObjectNode properties()Returns the value of thepropertiesrecord component.- Returns:
- the value of the
propertiesrecord component
-
nbt
-