Class Item
java.lang.Object
net.minecraft.world.item.Item
- All Implemented Interfaces:
FeatureElement, ItemLike, IItemExtension
- Direct Known Subclasses:
AirItem, ArmorStandItem, ArrowItem, AxeItem, BlockItem, BoatItem, BoneMealItem, BottleItem, BrushItem, BucketItem, BundleItem, CompassItem, DebugStickItem, DiscFragmentItem, DyeItem, EggItem, EmptyMapItem, EndCrystalItem, EnderEyeItem, EnderpearlItem, ExperienceBottleItem, FireChargeItem, FireworkRocketItem, FishingRodItem, FlintAndSteelItem, FoodOnAStickItem, GlowInkSacItem, HangingEntityItem, HoeItem, HoneycombItem, InkSacItem, InstrumentItem, KnowledgeBookItem, LeadItem, MaceItem, MapItem, MinecartItem, NameTagItem, PotionItem, ProjectileWeaponItem, ShearsItem, ShieldItem, ShovelItem, SmithingTemplateItem, SnowballItem, SpawnEggItem, SpyglassItem, TridentItem, WindChargeItem, WritableBookItem, WrittenBookItem
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected static final intstatic final Identifierstatic final Identifierprivate final Holder.Reference<Item> protected final booleanprivate final @Nullable ItemStackTemplatestatic final intprivate @Nullable ItemResourceprotected final Stringprivate static final org.slf4j.Loggerstatic final intprivate final FeatureFlagSetstatic final StreamCodec<RegistryFriendlyByteBuf, Holder<Item>> Fields inherited from interface FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendHoverText(ItemStack itemStack, Item.TooltipContext context, TooltipDisplay display, Consumer<Component> builder, TooltipFlag tooltipFlag) Deprecated.asItem()Deprecated.static ItemDeprecated.static ItembyId(int id) booleancanDestroyBlock(ItemStack itemStack, BlockState state, Level level, BlockPos pos, LivingEntity user) booleanDeprecated.computeDefaultResource(Function<Item, ItemResource> resourceConstructor) Deprecated.Neo: do not use, useItemResource.of(ItemStack)instead.finishUsingItem(ItemStack itemStack, Level level, LivingEntity entity) Called when the player finishes using this Item (E.g. finishes eating.).floatgetAttackDamageBonus(Entity victim, float damage, DamageSource damageSource) intgetBarColor(ItemStack stack) intgetBarWidth(ItemStack stack) final @Nullable ItemStackTemplateDeprecated.useIItemExtension.getCraftingRemainder(ItemStack)insteadintfinal StringfloatgetDestroySpeed(ItemStack itemStack, BlockState state) static int@Nullable DamageSourcegetItemDamageSource(LivingEntity attacker) Deprecated.static BlockHitResultgetPlayerPOVHitResult(Level level, Player player, ClipContext.Fluid fluid) getTooltipImage(ItemStack itemStack) getUseAnimation(ItemStack itemStack) intgetUseDuration(ItemStack itemStack, LivingEntity user) voidhurtEnemy(ItemStack itemStack, LivingEntity mob, LivingEntity attacker) interactLivingEntity(ItemStack itemStack, Player player, LivingEntity target, InteractionHand type) Try interacting with given entity.voidinventoryTick(ItemStack itemStack, ServerLevel level, Entity owner, @Nullable EquipmentSlot slot) booleanisBarVisible(ItemStack stack) booleanisCombineRepairable(ItemStack stack) Determines if an item is repairable by combining, used by Repair recipes and Grindstone.booleanisCorrectToolForDrops(ItemStack itemStack, BlockState state) booleanReturnstrueif this item has an enchantment glint.booleanmineBlock(ItemStack itemStack, Level level, BlockState state, BlockPos pos, LivingEntity owner) Called when aBlockis destroyed using this Item.voidonCraftedBy(ItemStack itemStack, Player player) voidonCraftedPostProcess(ItemStack itemStack, Level level) voidonDestroyed(ItemEntity itemEntity) Deprecated.voidonUseTick(Level level, LivingEntity livingEntity, ItemStack itemStack, int ticksRemaining) Called as the item is being used by an entity.booleanoverrideOtherStackedOnMe(ItemStack self, ItemStack other, Slot slot, ClickAction clickAction, Player player, SlotAccess carriedItem) booleanoverrideStackedOnOther(ItemStack self, Slot slot, ClickAction clickAction, Player player) voidpostHurtEnemy(ItemStack itemStack, LivingEntity mob, LivingEntity attacker) booleanreleaseUsing(ItemStack itemStack, Level level, LivingEntity entity, int remainingTime) voidDeprecated.Neo: do not use, useItemResource.of(ItemStack)instead.booleanshouldPrintOpWarning(ItemStack stack, @Nullable Player player) toString()use(Level level, Player player, InteractionHand hand) useOn(UseOnContext context) Called when this item is used when targeting a BlockbooleanuseOnRelease(ItemStack itemStack) If this stack's item is a crossbowMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface FeatureElement
isEnabledMethods inherited from interface IItemExtension
applyEnchantments, canBeHurtBy, canContinueUsing, canEquip, canFitInsideContainerItems, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, getAllEnchantments, getBurnTime, getCraftingRemainder, getCreatorModId, getDamage, getDefaultAttributeModifiers, getEnchantmentLevel, getEntityLifespan, getEquipmentSlot, getHighlightTip, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCustomEntity, isDamageable, isDamaged, isGazeDisguise, isNotReplaceableByPickAction, isPiglinCurrency, isPrimaryItemFor, makesPiglinsNeutral, onAnimalArmorTick, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onItemUseFirst, onLeftClickEntity, onStopUsing, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation, supportsEnchantment
-
Field Details
-
CODEC
-
STREAM_CODEC
-
CODEC_WITH_BOUND_COMPONENTS
-
LOGGER
private static final org.slf4j.Logger LOGGER -
BY_BLOCK
-
BASE_ATTACK_DAMAGE_ID
-
BASE_ATTACK_SPEED_ID
-
DEFAULT_MAX_STACK_SIZE
public static final int DEFAULT_MAX_STACK_SIZE- See Also:
-
ABSOLUTE_MAX_STACK_SIZE
public static final int ABSOLUTE_MAX_STACK_SIZE- See Also:
-
MAX_BAR_WIDTH
public static final int MAX_BAR_WIDTH- See Also:
-
APPROXIMATELY_INFINITE_USE_DURATION
protected static final int APPROXIMATELY_INFINITE_USE_DURATION- See Also:
-
builtInRegistryHolder
-
craftingRemainingItem
-
descriptionId
-
requiredFeatures
-
defaultResource
-
canCombineRepair
protected final boolean canCombineRepair
-
-
Constructor Details
-
Item
-
-
Method Details
-
getId
-
byId
-
byBlock
Deprecated. -
builtInRegistryHolder
Deprecated. -
components
-
resetDefaultResource
Deprecated.Neo: do not use, useItemResource.of(ItemStack)instead. -
computeDefaultResource
@Internal @Deprecated public ItemResource computeDefaultResource(Function<Item, ItemResource> resourceConstructor) Deprecated.Neo: do not use, useItemResource.of(ItemStack)instead. -
getDefaultMaxStackSize
public int getDefaultMaxStackSize() -
onUseTick
public void onUseTick(Level level, LivingEntity livingEntity, ItemStack itemStack, int ticksRemaining) Called as the item is being used by an entity. -
onDestroyed
Deprecated. -
canDestroyBlock
public boolean canDestroyBlock(ItemStack itemStack, BlockState state, Level level, BlockPos pos, LivingEntity user) -
asItem
-
useOn
Called when this item is used when targeting a Block -
getDestroySpeed
-
use
-
finishUsingItem
Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using the Item before the action is complete. -
isBarVisible
-
getBarWidth
-
getBarColor
-
overrideStackedOnOther
public boolean overrideStackedOnOther(ItemStack self, Slot slot, ClickAction clickAction, Player player) -
overrideOtherStackedOnMe
public boolean overrideOtherStackedOnMe(ItemStack self, ItemStack other, Slot slot, ClickAction clickAction, Player player, SlotAccess carriedItem) -
getAttackDamageBonus
-
getItemDamageSource
Deprecated. -
hurtEnemy
-
postHurtEnemy
-
mineBlock
public boolean mineBlock(ItemStack itemStack, Level level, BlockState state, BlockPos pos, LivingEntity owner) Called when aBlockis destroyed using this Item. Returntrueto trigger the "Use Item" statistic. -
isCorrectToolForDrops
-
interactLivingEntity
public InteractionResult interactLivingEntity(ItemStack itemStack, Player player, LivingEntity target, InteractionHand type) Try interacting with given entity. ReturnInteractionResult.PASSif nothing should happen. -
toString
-
getCraftingRemainder
Deprecated.useIItemExtension.getCraftingRemainder(ItemStack)instead -
inventoryTick
public void inventoryTick(ItemStack itemStack, ServerLevel level, Entity owner, @Nullable EquipmentSlot slot) -
onCraftedBy
-
onCraftedPostProcess
-
getUseAnimation
-
getUseDuration
-
releaseUsing
public boolean releaseUsing(ItemStack itemStack, Level level, LivingEntity entity, int remainingTime) -
appendHoverText
@Deprecated public void appendHoverText(ItemStack itemStack, Item.TooltipContext context, TooltipDisplay display, Consumer<Component> builder, TooltipFlag tooltipFlag) Deprecated. -
getTooltipImage
-
getDescriptionId
-
getName
-
isFoil
Returnstrueif this item has an enchantment glint. By default, this returnsstack.isEnchanted(), but other items can override it (for instance, written books always return true). Note that if you override this method, you generally want to also call the super version (onItem) to get the glint for enchanted items. Of course, that is unnecessary if the overwritten version always returns true. -
getPlayerPOVHitResult
public static BlockHitResult getPlayerPOVHitResult(Level level, Player player, ClipContext.Fluid fluid) -
useOnRelease
If this stack's item is a crossbow -
isCombineRepairable
Description copied from interface:IItemExtensionDetermines if an item is repairable by combining, used by Repair recipes and Grindstone.- Specified by:
isCombineRepairablein interfaceIItemExtension- Returns:
- True if repairable by combining
-
getDefaultInstance
-
canFitInsideContainerItems
Deprecated.Neo: callIItemStackExtension.canFitInsideContainerItems()instead, prefer overridingIItemExtension.canFitInsideContainerItems(ItemStack) -
requiredFeatures
- Specified by:
requiredFeaturesin interfaceFeatureElement
-
shouldPrintOpWarning
-
IItemStackExtension.canFitInsideContainerItems()instead, prefer overridingIItemExtension.canFitInsideContainerItems(ItemStack)