Record Class BattleSceneBlockData

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.battles.scene.BattleSceneBlockData
Record Components:
pos - the structure-relative or client-ready block position
state - the block state to render in the scene
nbt - copied block entity data, or null when the block has none

public record BattleSceneBlockData(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.nbt.CompoundTag nbt) extends Record
Serializable block snapshot for a battle scene.

These are extracted from a server-side structure and sent to the client so the scene can be rendered without the client needing direct access to the server's structure manager.

  • Constructor Summary

    Constructors
    Constructor
    Description
    BattleSceneBlockData(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.nbt.CompoundTag nbt)
    Creates a block snapshot and defensively copies the supplied block entity data.
    BattleSceneBlockData(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo blockInfo)
    Creates a serializable block snapshot from a structure template block.
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(net.minecraft.network.FriendlyByteBuf buffer)
    Decodes a scene block snapshot from the network.
    void
    encode(net.minecraft.network.FriendlyByteBuf buffer)
    Encodes this scene block snapshot for the client.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @Nullable net.minecraft.nbt.CompoundTag
    nbt()
    Returns the value of the nbt record component.
    offset(net.minecraft.core.BlockPos offset)
    Returns a copy of this block shifted by the supplied offset.
    net.minecraft.core.BlockPos
    pos()
    Returns the value of the pos record component.
    net.minecraft.world.level.block.state.BlockState
    Returns the value of the state 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

    • BattleSceneBlockData

      public BattleSceneBlockData(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.nbt.CompoundTag nbt)
      Creates a block snapshot and defensively copies the supplied block entity data.
      Parameters:
      pos - the block position
      state - the block state
      nbt - block entity data to copy, or null
    • BattleSceneBlockData

      public BattleSceneBlockData(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo blockInfo)
      Creates a serializable block snapshot from a structure template block.
      Parameters:
      blockInfo - the structure block information to copy
  • Method Details

    • offset

      public BattleSceneBlockData offset(net.minecraft.core.BlockPos offset)
      Returns a copy of this block shifted by the supplied offset.
      Parameters:
      offset - the block position offset to apply
      Returns:
      the shifted block data
    • decode

      public static BattleSceneBlockData decode(net.minecraft.network.FriendlyByteBuf buffer)
      Decodes a scene block snapshot from the network.
      Parameters:
      buffer - the packet buffer to read from
      Returns:
      the decoded block data
    • encode

      public void encode(net.minecraft.network.FriendlyByteBuf buffer)
      Encodes this scene block snapshot for the client.
      Parameters:
      buffer - the packet buffer to write to
    • 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

      public net.minecraft.core.BlockPos pos()
      Returns the value of the pos record component.
      Returns:
      the value of the pos record component
    • state

      public net.minecraft.world.level.block.state.BlockState state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • nbt

      @Nullable public @Nullable net.minecraft.nbt.CompoundTag nbt()
      Returns the value of the nbt record component.
      Returns:
      the value of the nbt record component