Interface BlockSource

All Known Implementing Classes:
BlockSource.HeldBlock, BlockSource.HeldItem

public sealed interface BlockSource permits BlockSource.HeldBlock, BlockSource.HeldItem
Where a line's blocks come from: a block in hand (plus inventory and supplies), or an item that picks blocks.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A block in hand.
    static final record 
    A non-block item that places blocks, see HeldItemHandler.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    allowed(net.minecraft.world.item.ItemStack block, LinearSettings settings)
    Whether a block may be used in a line, checking the blacklist or whitelist.
    int
    available(net.minecraft.world.entity.player.Player player, int wanted)
    How many blocks there are for the line, at most wanted.
    static @Nullable net.minecraft.world.InteractionHand
    drawingHand(net.minecraft.world.entity.player.Player player)
    The hand to draw a line with (main hand first), or null.
    void
    giveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block)
    Puts back a block that was taken but not placed.
    static @Nullable BlockSource
    of(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
    What the player can draw a line with in hand, or null if nothing.
    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.
  • Method Details

    • preview

      net.minecraft.world.item.ItemStack preview(net.minecraft.world.entity.player.Player player)
      The block the preview shows.
    • available

      int available(net.minecraft.world.entity.player.Player player, int wanted)
      How many blocks there are for the line, at most wanted. Creative players have no limit.
    • takeOne

      net.minecraft.world.item.ItemStack takeOne(net.minecraft.server.level.ServerPlayer player)
      Takes the next block, or returns empty if there are none left.
    • giveBack

      void giveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block)
      Puts back a block that was taken but not placed.
    • of

      @Nullable static @Nullable BlockSource of(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
      What the player can draw a line with in hand, or null if nothing.
    • drawingHand

      @Nullable static @Nullable net.minecraft.world.InteractionHand drawingHand(net.minecraft.world.entity.player.Player player)
      The hand to draw a line with (main hand first), or null.
    • allowed

      static boolean allowed(net.minecraft.world.item.ItemStack block, LinearSettings settings)
      Whether a block may be used in a line, checking the blacklist or whitelist.