Package net.minecraft.item
Class BlockItem
java.lang.Object
net.minecraft.item.Item
net.minecraft.item.BlockItem
- All Implemented Interfaces:
ItemConvertible,ToggleableFeature
- Direct Known Subclasses:
AliasedBlockItem,BedItem,OperatorOnlyBlockItem,PlaceableOnWaterItem,PowderSnowBucketItem,ScaffoldingItem,TallBlockItem,VerticallyAttachableBlockItem
Represents an item corresponding to a block. Using this item places a
block in the world.
- Mappings:
Namespace Name official cdqintermediary net/minecraft/class_1747named net/minecraft/item/BlockItem
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.item.Item
Item.Settings -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BlockDeprecated.static final Stringstatic final StringFields inherited from class net.minecraft.item.Item
ATTACK_DAMAGE_MODIFIER_ID, ATTACK_SPEED_MODIFIER_ID, BLOCK_ITEMS, DEFAULT_MAX_COUNT, DEFAULT_MAX_USE_TIME, ITEM_BAR_STEPSFields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendBlocks(Map<Block, Item> map, Item item) voidappendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) Called by the client to append tooltips to an item.booleanprotected booleancanPlace(ItemPlacementContext context, BlockState state) protected booleangetBlock()static @Nullable NbtCompoundgetBlockEntityNbt(ItemStack stack) getPlacementContext(ItemPlacementContext context) protected @Nullable BlockStategetPlacementState(ItemPlacementContext context) protected SoundEventgetPlaceSound(BlockState state) Gets the translation key of this item.voidonItemEntityDestroyed(ItemEntity entity) Called on the server when anItemEntityholding this item gets destroyed.place(ItemPlacementContext context) protected booleanplace(ItemPlacementContext context, BlockState state) private BlockStateplaceFromNbt(BlockPos pos, World world, ItemStack stack, BlockState state) protected booleanpostPlacement(BlockPos pos, World world, @Nullable PlayerEntity player, ItemStack stack, BlockState state) static voidsetBlockEntityNbt(ItemStack stack, BlockEntityType<?> blockEntityType, NbtCompound tag) useOnBlock(ItemUsageContext context) Called when an item is used on a block.private static <T extends Comparable<T>>
BlockStatewith(BlockState state, Property<T> property, String name) static booleanwriteNbtToBlockEntity(World world, @Nullable PlayerEntity player, BlockPos pos, ItemStack stack) Methods inherited from class net.minecraft.item.Item
asItem, byRawId, canMine, canRepair, damage, finishUsing, fromBlock, getAttributeModifiers, getDefaultStack, getDrinkSound, getEatSound, getEnchantability, getFoodComponent, getItemBarColor, getItemBarStep, getMaxCount, getMaxDamage, getMaxUseTime, getMiningSpeedMultiplier, getName, getName, getOrCreateTranslationKey, getRarity, getRawId, getRecipeRemainder, getRegistryEntry, getTooltipData, getTranslationKey, getUseAction, hasGlint, hasRecipeRemainder, inventoryTick, isDamageable, isEnchantable, isFireproof, isFood, isItemBarVisible, isNbtSynced, isNetworkSynced, isSuitableFor, isUsedOnRelease, onClicked, onCraft, onStackClicked, onStoppedUsing, postHit, postMine, postProcessNbt, raycast, toString, usageTick, use, useOnEntityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Field Details
-
BLOCK_ENTITY_TAG_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector official aLcdq;a:Ljava/lang/String;intermediary field_30849Lnet/minecraft/class_1747;field_30849:Ljava/lang/String;named BLOCK_ENTITY_TAG_KEYLnet/minecraft/item/BlockItem;BLOCK_ENTITY_TAG_KEY:Ljava/lang/String;
-
BLOCK_STATE_TAG_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector official bLcdq;b:Ljava/lang/String;intermediary field_30850Lnet/minecraft/class_1747;field_30850:Ljava/lang/String;named BLOCK_STATE_TAG_KEYLnet/minecraft/item/BlockItem;BLOCK_STATE_TAG_KEY:Ljava/lang/String;
-
block
Deprecated.- Mappings:
Namespace Name Mixin selector official cLcdq;c:Lcpl;intermediary field_7901Lnet/minecraft/class_1747;field_7901:Lnet/minecraft/class_2248;named blockLnet/minecraft/item/BlockItem;block:Lnet/minecraft/block/Block;
-
-
Constructor Details
-
BlockItem
- Mappings:
Namespace Name Mixin selector official <init>Lcdq;<init>(Lcpl;Lcfs$a;)Vintermediary <init>Lnet/minecraft/class_1747;<init>(Lnet/minecraft/class_2248;Lnet/minecraft/class_1792$class_1793;)Vnamed <init>Lnet/minecraft/item/BlockItem;<init>(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item$Settings;)V
-
-
Method Details
-
useOnBlock
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:
useOnBlockin classItem- 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 aLcfs;a(Lcih;)Lbdw;intermediary method_7884Lnet/minecraft/class_1792;method_7884(Lnet/minecraft/class_1838;)Lnet/minecraft/class_1269;named useOnBlockLnet/minecraft/item/Item;useOnBlock(Lnet/minecraft/item/ItemUsageContext;)Lnet/minecraft/util/ActionResult;
-
place
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Lcif;)Lbdw;intermediary method_7712Lnet/minecraft/class_1747;method_7712(Lnet/minecraft/class_1750;)Lnet/minecraft/class_1269;named placeLnet/minecraft/item/BlockItem;place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;
-
getPlaceSound
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Ldby;)Lamg;intermediary method_19260Lnet/minecraft/class_1747;method_19260(Lnet/minecraft/class_2680;)Lnet/minecraft/class_3414;named getPlaceSoundLnet/minecraft/item/BlockItem;getPlaceSound(Lnet/minecraft/block/BlockState;)Lnet/minecraft/sound/SoundEvent;
-
getPlacementContext
- Mappings:
Namespace Name Mixin selector official bLcdq;b(Lcif;)Lcif;intermediary method_16356Lnet/minecraft/class_1747;method_16356(Lnet/minecraft/class_1750;)Lnet/minecraft/class_1750;named getPlacementContextLnet/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 aLcdq;a(Lgu;Lcmk;Lbym;Lcfx;Ldby;)Zintermediary method_7710Lnet/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;)Znamed postPlacementLnet/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
- Mappings:
Namespace Name Mixin selector official cLcdq;c(Lcif;)Ldby;intermediary method_7707Lnet/minecraft/class_1747;method_7707(Lnet/minecraft/class_1750;)Lnet/minecraft/class_2680;named getPlacementStateLnet/minecraft/item/BlockItem;getPlacementState(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/block/BlockState;
-
placeFromNbt
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Lgu;Lcmk;Lcfx;Ldby;)Ldby;intermediary method_18084Lnet/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 placeFromNbtLnet/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 aLcdq;a(Ldby;Lddb;Ljava/lang/String;)Ldby;intermediary method_18083Lnet/minecraft/class_1747;method_18083(Lnet/minecraft/class_2680;Lnet/minecraft/class_2769;Ljava/lang/String;)Lnet/minecraft/class_2680;named withLnet/minecraft/item/BlockItem;with(Lnet/minecraft/block/BlockState;Lnet/minecraft/state/property/Property;Ljava/lang/String;)Lnet/minecraft/block/BlockState;
-
canPlace
- Mappings:
Namespace Name Mixin selector official bLcdq;b(Lcif;Ldby;)Zintermediary method_7709Lnet/minecraft/class_1747;method_7709(Lnet/minecraft/class_1750;Lnet/minecraft/class_2680;)Znamed canPlaceLnet/minecraft/item/BlockItem;canPlace(Lnet/minecraft/item/ItemPlacementContext;Lnet/minecraft/block/BlockState;)Z
-
checkStatePlacement
protected boolean checkStatePlacement()- Mappings:
Namespace Name Mixin selector official dLcdq;d()Zintermediary method_20360Lnet/minecraft/class_1747;method_20360()Znamed checkStatePlacementLnet/minecraft/item/BlockItem;checkStatePlacement()Z
-
place
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Lcif;Ldby;)Zintermediary method_7708Lnet/minecraft/class_1747;method_7708(Lnet/minecraft/class_1750;Lnet/minecraft/class_2680;)Znamed placeLnet/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 aLcdq;a(Lcmk;Lbym;Lgu;Lcfx;)Zintermediary method_7714Lnet/minecraft/class_1747;method_7714(Lnet/minecraft/class_1937;Lnet/minecraft/class_1657;Lnet/minecraft/class_2338;Lnet/minecraft/class_1799;)Znamed writeNbtToBlockEntityLnet/minecraft/item/BlockItem;writeNbtToBlockEntity(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/item/ItemStack;)Z
-
getTranslationKey
Gets the translation key of this item.- Overrides:
getTranslationKeyin classItem- Mappings:
Namespace Name Mixin selector official aLcfs;a()Ljava/lang/String;intermediary method_7876Lnet/minecraft/class_1792;method_7876()Ljava/lang/String;named getTranslationKeyLnet/minecraft/item/Item;getTranslationKey()Ljava/lang/String;
-
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 totooltiplist.- Overrides:
appendTooltipin classItem- Parameters:
tooltip- the list of tooltips to show- Mappings:
Namespace Name Mixin selector official aLcfs;a(Lcfx;Lcmk;Ljava/util/List;Lcho;)Vintermediary method_7851Lnet/minecraft/class_1792;method_7851(Lnet/minecraft/class_1799;Lnet/minecraft/class_1937;Ljava/util/List;Lnet/minecraft/class_1836;)Vnamed appendTooltipLnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Ljava/util/List;Lnet/minecraft/client/item/TooltipContext;)V
-
getBlock
- Mappings:
Namespace Name Mixin selector official eLcdq;e()Lcpl;intermediary method_7711Lnet/minecraft/class_1747;method_7711()Lnet/minecraft/class_2248;named getBlockLnet/minecraft/item/BlockItem;getBlock()Lnet/minecraft/block/Block;
-
appendBlocks
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Ljava/util/Map;Lcfs;)Vintermediary method_7713Lnet/minecraft/class_1747;method_7713(Ljava/util/Map;Lnet/minecraft/class_1792;)Vnamed appendBlocksLnet/minecraft/item/BlockItem;appendBlocks(Ljava/util/Map;Lnet/minecraft/item/Item;)V
-
canBeNested
public boolean canBeNested()- Overrides:
canBeNestedin classItem- Returns:
- true if the item can be placed inside of shulker boxes or bundles.
- Mappings:
Namespace Name Mixin selector official ag_Lcfs;ag_()Zintermediary method_31568Lnet/minecraft/class_1792;method_31568()Znamed canBeNestedLnet/minecraft/item/Item;canBeNested()Z
-
onItemEntityDestroyed
Called on the server when anItemEntityholding 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:
onItemEntityDestroyedin classItem- See Also:
- Mappings:
Namespace Name Mixin selector official aLcfs;a(Lbvf;)Vintermediary method_33261Lnet/minecraft/class_1792;method_33261(Lnet/minecraft/class_1542;)Vnamed onItemEntityDestroyedLnet/minecraft/item/Item;onItemEntityDestroyed(Lnet/minecraft/entity/ItemEntity;)V
-
getBlockEntityNbt
- Mappings:
Namespace Name Mixin selector official aLcdq;a(Lcfx;)Lqr;intermediary method_38072Lnet/minecraft/class_1747;method_38072(Lnet/minecraft/class_1799;)Lnet/minecraft/class_2487;named getBlockEntityNbtLnet/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 aLcdq;a(Lcfx;Lczm;Lqr;)Vintermediary method_38073Lnet/minecraft/class_1747;method_38073(Lnet/minecraft/class_1799;Lnet/minecraft/class_2591;Lnet/minecraft/class_2487;)Vnamed setBlockEntityNbtLnet/minecraft/item/BlockItem;setBlockEntityNbt(Lnet/minecraft/item/ItemStack;Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/nbt/NbtCompound;)V
-
getRequiredFeatures
- Specified by:
getRequiredFeaturesin interfaceToggleableFeature- Overrides:
getRequiredFeaturesin classItem- Mappings:
Namespace Name Mixin selector official mLcar;m()Lcau;intermediary method_45322Lnet/minecraft/class_7695;method_45322()Lnet/minecraft/class_7699;named getRequiredFeaturesLnet/minecraft/resource/featuretoggle/ToggleableFeature;getRequiredFeatures()Lnet/minecraft/resource/featuretoggle/FeatureSet;
-