Class BlockItem

java.lang.Object
net.minecraft.item.Item
net.minecraft.item.BlockItem
All Implemented Interfaces:
ItemConvertible
Direct Known Subclasses:
AliasedBlockItem, BedItem, CommandBlockItem, PlaceableOnWaterItem, PowderSnowBucketItem, ScaffoldingItem, TallBlockItem, WallStandingBlockItem

public class BlockItem extends Item
Represents an item corresponding to a block. Using this item places a block in the world.
Mappings:
Namespace Name
official byx
intermediary net/minecraft/class_1747
named net/minecraft/item/BlockItem
  • Field Details

    • BLOCK_ENTITY_TAG_KEY

      private static final String BLOCK_ENTITY_TAG_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official b Lbyx;b:Ljava/lang/String;
      intermediary field_30849 Lnet/minecraft/class_1747;field_30849:Ljava/lang/String;
      named BLOCK_ENTITY_TAG_KEY Lnet/minecraft/item/BlockItem;BLOCK_ENTITY_TAG_KEY:Ljava/lang/String;
    • BLOCK_STATE_TAG_KEY

      public static final String BLOCK_STATE_TAG_KEY
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a:Ljava/lang/String;
      intermediary field_30850 Lnet/minecraft/class_1747;field_30850:Ljava/lang/String;
      named BLOCK_STATE_TAG_KEY Lnet/minecraft/item/BlockItem;BLOCK_STATE_TAG_KEY:Ljava/lang/String;
    • block

      @Deprecated private final Block block
      Deprecated.
      Mappings:
      Namespace Name Mixin selector
      official c Lbyx;c:Lcjt;
      intermediary field_7901 Lnet/minecraft/class_1747;field_7901:Lnet/minecraft/class_2248;
      named block Lnet/minecraft/item/BlockItem;block:Lnet/minecraft/block/Block;
  • Constructor Details

    • BlockItem

      public BlockItem(Block block, Item.Settings settings)
      Mappings:
      Namespace Name Mixin selector
      official <init> Lbyx;<init>(Lcjt;Lcat$a;)V
      intermediary <init> Lnet/minecraft/class_1747;<init>(Lnet/minecraft/class_2248;Lnet/minecraft/class_1792$class_1793;)V
      named <init> Lnet/minecraft/item/BlockItem;<init>(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item$Settings;)V
  • Method Details

    • useOnBlock

      public ActionResult useOnBlock(ItemUsageContext context)
      Called when an item is used on a block.

      This method is called on both the logical client and logical server, so take caution when using this method. The logical side can be checked using context.getWorld().isClient().

      Overrides:
      useOnBlock in class Item
      Parameters:
      context - the usage context
      Returns:
      an action result that specifies if using the item on a block was successful.
      Mappings:
      Namespace Name Mixin selector
      official a Lcat;a(Lccz;)Lbaj;
      intermediary method_7884 Lnet/minecraft/class_1792;method_7884(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;
      named useOnBlock Lnet/minecraft/item/Item;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;
    • place

      public ActionResult place(ItemPlacementContext context)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lccx;)Lbaj;
      intermediary method_7712 Lnet/minecraft/class_1747;method_7712(Lnet/minecraft/class_1750;)Lnet/minecraft/class_1269;
      named place Lnet/minecraft/item/BlockItem;place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;
    • getPlaceSound

      protected SoundEvent getPlaceSound(BlockState state)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lcvo;)Lajv;
      intermediary method_19260 Lnet/minecraft/class_1747;method_19260(Lnet/minecraft/class_2680;)Lnet/minecraft/class_3414;
      named getPlaceSound Lnet/minecraft/item/BlockItem;getPlaceSound(Lnet/minecraft/block/BlockState;)Lnet/minecraft/sound/SoundEvent;
    • getPlacementContext

      @Nullable public @Nullable ItemPlacementContext getPlacementContext(ItemPlacementContext context)
      Mappings:
      Namespace Name Mixin selector
      official b Lbyx;b(Lccx;)Lccx;
      intermediary method_16356 Lnet/minecraft/class_1747;method_16356(Lnet/minecraft/class_1750;)Lnet/minecraft/class_1750;
      named getPlacementContext Lnet/minecraft/item/BlockItem;getPlacementContext(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/item/ItemPlacementContext;
    • postPlacement

      protected boolean postPlacement(BlockPos pos, World world, @Nullable @Nullable PlayerEntity player, ItemStack stack, BlockState state)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lgt;Lcgx;Lbuc;Lcax;Lcvo;)Z
      intermediary method_7710 Lnet/minecraft/class_1747;method_7710(Lnet/minecraft/class_2338;Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Z
      named postPlacement Lnet/minecraft/item/BlockItem;postPlacement(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)Z
    • getPlacementState

      @Nullable protected @Nullable BlockState getPlacementState(ItemPlacementContext context)
      Mappings:
      Namespace Name Mixin selector
      official c Lbyx;c(Lccx;)Lcvo;
      intermediary method_7707 Lnet/minecraft/class_1747;method_7707(Lnet/minecraft/class_1750;)Lnet/minecraft/class_2680;
      named getPlacementState Lnet/minecraft/item/BlockItem;getPlacementState(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/block/BlockState;
    • placeFromNbt

      private BlockState placeFromNbt(BlockPos pos, World world, ItemStack stack, BlockState state)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lgt;Lcgx;Lcax;Lcvo;)Lcvo;
      intermediary method_18084 Lnet/minecraft/class_1747;method_18084(Lnet/minecraft/class_2338;Lnet/minecraft/class_1937;Lnet/minecraft/class_1799;Lnet/minecraft/class_2680;)Lnet/minecraft/class_2680;
      named placeFromNbt Lnet/minecraft/item/BlockItem;placeFromNbt(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;
    • with

      private static <T extends Comparable<T>> BlockState with(BlockState state, Property<T> property, String name)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lcvo;Lcwr;Ljava/lang/String;)Lcvo;
      intermediary method_18083 Lnet/minecraft/class_1747;method_18083(Lnet/minecraft/class_2680;Lnet/minecraft/class_2769;Ljava/lang/String;)Lnet/minecraft/class_2680;
      named with Lnet/minecraft/item/BlockItem;with(Lnet/minecraft/block/BlockState;Lnet/minecraft/state/property/Property;Ljava/lang/String;)Lnet/minecraft/block/BlockState;
    • canPlace

      protected boolean canPlace(ItemPlacementContext context, BlockState state)
      Mappings:
      Namespace Name Mixin selector
      official b Lbyx;b(Lccx;Lcvo;)Z
      intermediary method_7709 Lnet/minecraft/class_1747;method_7709(Lnet/minecraft/class_1750;Lnet/minecraft/class_2680;)Z
      named canPlace Lnet/minecraft/item/BlockItem;canPlace(Lnet/minecraft/item/ItemPlacementContext;Lnet/minecraft/block/BlockState;)Z
    • checkStatePlacement

      protected boolean checkStatePlacement()
      Mappings:
      Namespace Name Mixin selector
      official d Lbyx;d()Z
      intermediary method_20360 Lnet/minecraft/class_1747;method_20360()Z
      named checkStatePlacement Lnet/minecraft/item/BlockItem;checkStatePlacement()Z
    • place

      protected boolean place(ItemPlacementContext context, BlockState state)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lccx;Lcvo;)Z
      intermediary method_7708 Lnet/minecraft/class_1747;method_7708(Lnet/minecraft/class_1750;Lnet/minecraft/class_2680;)Z
      named place Lnet/minecraft/item/BlockItem;place(Lnet/minecraft/item/ItemPlacementContext;Lnet/minecraft/block/BlockState;)Z
    • writeNbtToBlockEntity

      public static boolean writeNbtToBlockEntity(World world, @Nullable @Nullable PlayerEntity player, BlockPos pos, ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lcgx;Lbuc;Lgt;Lcax;)Z
      intermediary method_7714 Lnet/minecraft/class_1747;method_7714(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_2338;Lnet/minecraft/class_1799;)Z
      named writeNbtToBlockEntity Lnet/minecraft/item/BlockItem;writeNbtToBlockEntity(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)Z
    • getTranslationKey

      public String getTranslationKey()
      Gets the translation key of this item.
      Overrides:
      getTranslationKey in class Item
      Mappings:
      Namespace Name Mixin selector
      official a Lcat;a()Ljava/lang/String;
      intermediary method_7876 Lnet/minecraft/class_1792;method_7876()Ljava/lang/String;
      named getTranslationKey Lnet/minecraft/item/Item;getTranslationKey()Ljava/lang/String;
    • appendStacks

      public void appendStacks(ItemGroup group, DefaultedList<ItemStack> stacks)
      Appends the stacks of this item shown in the item group to the list.

      This can be overridden to append item stacks with custom NBT data to the creative inventory.

      Overrides:
      appendStacks in class Item
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcat;a(Lbzj;Lhi;)V
      intermediary method_7850 Lnet/minecraft/class_1792;method_7850(Lnet/minecraft/class_1761;Lnet/minecraft/class_2371;)V
      named appendStacks Lnet/minecraft/item/Item;appendStacks(Lnet/minecraft/item/ItemGroup;Lnet/minecraft/util/collection/DefaultedList;)V
    • appendTooltip

      public void appendTooltip(ItemStack stack, @Nullable @Nullable World world, List<Text> tooltip, TooltipContext context)
      Called by the client to append tooltips to an item. Subclasses can override this and add custom tooltips to tooltip list.
      Overrides:
      appendTooltip in class Item
      Parameters:
      tooltip - the list of tooltips to show
      Mappings:
      Namespace Name Mixin selector
      official a Lcat;a(Lcax;Lcgx;Ljava/util/List;Lccl;)V
      intermediary method_7851 Lnet/minecraft/class_1792;method_7851(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Ljava/util/List;Lnet/minecraft/class_1836;)V
      named appendTooltip Lnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Ljava/util/List;Lnet/minecraft/client/item/TooltipContext;)V
    • getBlock

      public Block getBlock()
      Mappings:
      Namespace Name Mixin selector
      official e Lbyx;e()Lcjt;
      intermediary method_7711 Lnet/minecraft/class_1747;method_7711()Lnet/minecraft/class_2248;
      named getBlock Lnet/minecraft/item/BlockItem;getBlock()Lnet/minecraft/block/Block;
    • appendBlocks

      public void appendBlocks(Map<Block,Item> map, Item item)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Ljava/util/Map;Lcat;)V
      intermediary method_7713 Lnet/minecraft/class_1747;method_7713(Ljava/util/Map;Lnet/minecraft/class_1792;)V
      named appendBlocks Lnet/minecraft/item/BlockItem;appendBlocks(Ljava/util/Map;Lnet/minecraft/item/Item;)V
    • canBeNested

      public boolean canBeNested()
      Overrides:
      canBeNested in class Item
      Returns:
      true if the item can be placed inside of shulker boxes or bundles.
      Mappings:
      Namespace Name Mixin selector
      official S_ Lcat;S_()Z
      intermediary method_31568 Lnet/minecraft/class_1792;method_31568()Z
      named canBeNested Lnet/minecraft/item/Item;canBeNested()Z
    • onItemEntityDestroyed

      public void onItemEntityDestroyed(ItemEntity entity)
      Called on the server when an ItemEntity holding this item gets destroyed. This can happen due to fire, lava, cactus, explosion, etc. Items that can hold other items should override this to drop its contents.
      Overrides:
      onItemEntityDestroyed in class Item
      See Also:
      Mappings:
      Namespace Name Mixin selector
      official a Lcat;a(Lbqv;)V
      intermediary method_33261 Lnet/minecraft/class_1792;method_33261(Lnet/minecraft/class_1542;)V
      named onItemEntityDestroyed Lnet/minecraft/item/Item;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)V
    • getBlockEntityNbt

      @Nullable public static @Nullable NbtCompound getBlockEntityNbt(ItemStack stack)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lcax;)Lpj;
      intermediary method_38072 Lnet/minecraft/class_1747;method_38072(Lnet/minecraft/class_1799;)Lnet/minecraft/class_2487;
      named getBlockEntityNbt Lnet/minecraft/item/BlockItem;getBlockEntityNbt(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/nbt/NbtCompound;
    • setBlockEntityNbt

      public static void setBlockEntityNbt(ItemStack stack, BlockEntityType<?> blockEntityType, NbtCompound tag)
      Mappings:
      Namespace Name Mixin selector
      official a Lbyx;a(Lcax;Lctk;Lpj;)V
      intermediary method_38073 Lnet/minecraft/class_1747;method_38073(Lnet/minecraft/class_1799;Lnet/minecraft/class_2591;Lnet/minecraft/class_2487;)V
      named setBlockEntityNbt Lnet/minecraft/item/BlockItem;setBlockEntityNbt(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/nbt/NbtCompound;)V