Record Class CapturedBlock

java.lang.Object
java.lang.Record
com.ldtteam.structurize.component.CapturedBlock
Record Components:
blockState - state of captured block
serializedBE - related blockEntity data if needed
itemStack - itemStack representing both block and blockEntity

public record CapturedBlock(net.minecraft.world.level.block.state.BlockState blockState, Optional<net.minecraft.nbt.CompoundTag> serializedBE, net.minecraft.world.item.ItemStack itemStack) extends Record
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<CapturedBlock>
     
    static final CapturedBlock
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,CapturedBlock>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CapturedBlock(net.minecraft.world.level.block.state.BlockState blockState, Optional<net.minecraft.nbt.CompoundTag> serializedBE, net.minecraft.world.item.ItemStack itemStack)
    Creates an instance of a CapturedBlock record class.
    CapturedBlock(net.minecraft.world.level.block.state.BlockState blockState, @Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.core.HolderLookup.Provider provider, net.minecraft.world.item.ItemStack itemStack)
    Serializes given BE.
  • Method Summary

    Modifier and Type
    Method
    Description
    applyRotationMirror(RotationMirror rotationMirror, net.minecraft.world.level.Level level)
     
    net.minecraft.world.level.block.state.BlockState
    Returns the value of the blockState record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
     
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.ItemStack
    Returns the value of the itemStack record component.
    readFromItemStack(net.minecraft.world.item.ItemStack itemStack)
     
    Optional<net.minecraft.nbt.CompoundTag>
    Returns the value of the serializedBE record component.
    final String
    Returns a string representation of this record class.
    static void
    updateItemStack(net.minecraft.world.item.ItemStack itemStack, UnaryOperator<CapturedBlock> updater)
    Performs updating of posSelection in given itemStack
    void
    writeToItemStack(net.minecraft.world.item.ItemStack itemStack)
    Writes this posSelection into given itemStack.

    Methods inherited from class java.lang.Object

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

    • EMPTY

      public static final CapturedBlock EMPTY
    • CODEC

      public static final com.mojang.serialization.Codec<CapturedBlock> CODEC
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,CapturedBlock> STREAM_CODEC
  • Constructor Details

    • CapturedBlock

      public CapturedBlock(net.minecraft.world.level.block.state.BlockState blockState, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.core.HolderLookup.Provider provider, net.minecraft.world.item.ItemStack itemStack)
      Serializes given BE.
      Parameters:
      blockState - state of captured block
      blockEntity - related blockEntity data if needed
      provider - registry access
      itemStack - itemStack representing both block and blockEntity
    • CapturedBlock

      public CapturedBlock(net.minecraft.world.level.block.state.BlockState blockState, Optional<net.minecraft.nbt.CompoundTag> serializedBE, net.minecraft.world.item.ItemStack itemStack)
      Creates an instance of a CapturedBlock record class.
      Parameters:
      blockState - the value for the blockState record component
      serializedBE - the value for the serializedBE record component
      itemStack - the value for the itemStack record component
  • Method Details

    • applyRotationMirror

      public CapturedBlock applyRotationMirror(RotationMirror rotationMirror, net.minecraft.world.level.Level level)
      Parameters:
      rotationMirror - relative rotation and mirror
      level - registry access
    • hasBlockEntity

      public boolean hasBlockEntity()
    • writeToItemStack

      public void writeToItemStack(net.minecraft.world.item.ItemStack itemStack)
      Writes this posSelection into given itemStack.
      See Also:
      • BlockEntity.saveToItem(ItemStack, net.minecraft.core.HolderLookup.Provider)
    • readFromItemStack

      public static CapturedBlock readFromItemStack(net.minecraft.world.item.ItemStack itemStack)
      Returns:
      posSelection stored in given itemStack (or empty instance)
    • updateItemStack

      public static void updateItemStack(net.minecraft.world.item.ItemStack itemStack, UnaryOperator<CapturedBlock> updater)
      Performs updating of posSelection in given itemStack
    • 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.
    • blockState

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

      public Optional<net.minecraft.nbt.CompoundTag> serializedBE()
      Returns the value of the serializedBE record component.
      Returns:
      the value of the serializedBE record component
    • itemStack

      public net.minecraft.world.item.ItemStack itemStack()
      Returns the value of the itemStack record component.
      Returns:
      the value of the itemStack record component