Record Class BlockSource.HeldBlock

java.lang.Object
java.lang.Record
tschipp.linear.build.BlockSource.HeldBlock
All Implemented Interfaces:
BlockSource
Enclosing interface:
BlockSource

public static record BlockSource.HeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template) extends Record implements BlockSource
A block in hand. Uses the held stack first, then matching stacks in the inventory, then each BlockSupply. The last block in hand is only used once everything else is empty.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface tschipp.linear.build.BlockSource

    BlockSource.HeldBlock, BlockSource.HeldItem
  • Constructor Summary

    Constructors
    Constructor
    Description
    HeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template)
    Creates an instance of a HeldBlock record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    available(net.minecraft.world.entity.player.Player player, int wanted)
    How many blocks there are for the line, at most wanted.
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    giveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block)
    Puts back a block that was taken but not placed.
    net.minecraft.world.InteractionHand
    Returns the value of the hand record component.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.ItemStack
    preview(net.minecraft.world.entity.player.Player player)
    The block the preview shows.
    net.minecraft.world.item.ItemStack
    takeOne(net.minecraft.server.level.ServerPlayer player)
    Takes the next block, or returns empty if there are none left.
    net.minecraft.world.item.ItemStack
    Returns the value of the template 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

    • HeldBlock

      public HeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template)
      Creates an instance of a HeldBlock record class.
      Parameters:
      hand - the value for the hand record component
      template - the value for the template record component
  • Method Details

    • preview

      public net.minecraft.world.item.ItemStack preview(net.minecraft.world.entity.player.Player player)
      Description copied from interface: BlockSource
      The block the preview shows.
      Specified by:
      preview in interface BlockSource
    • available

      public int available(net.minecraft.world.entity.player.Player player, int wanted)
      Description copied from interface: BlockSource
      How many blocks there are for the line, at most wanted. Creative players have no limit.
      Specified by:
      available in interface BlockSource
    • takeOne

      public net.minecraft.world.item.ItemStack takeOne(net.minecraft.server.level.ServerPlayer player)
      Description copied from interface: BlockSource
      Takes the next block, or returns empty if there are none left.
      Specified by:
      takeOne in interface BlockSource
    • giveBack

      public void giveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block)
      Description copied from interface: BlockSource
      Puts back a block that was taken but not placed.
      Specified by:
      giveBack in interface BlockSource
    • 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.
    • hand

      public net.minecraft.world.InteractionHand hand()
      Returns the value of the hand record component.
      Returns:
      the value of the hand record component
    • template

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