Interface IForgeItem
- All Known Implementing Classes:
AirItem
,ArmorItem
,ArmorStandItem
,ArrowItem
,AxeItem
,BannerItem
,BannerPatternItem
,BedItem
,BlockItem
,BoatItem
,BoneMealItem
,BookItem
,BottleItem
,BowItem
,BowlFoodItem
,BrushItem
,BucketItem
,BundleItem
,ChorusFruitItem
,CompassItem
,ComplexItem
,CrossbowItem
,CustomArmorModelTest.EndermanArmorItem
,CustomArmorModelTest.TintedArmorItem
,CustomElytraTest.CustomElytra
,CustomFluidContainerTest.CustomFluidContainer
,CustomItemDisplayContextTest.ItemHangerItem
,CustomShieldTest.CustomShieldItem
,CustomTooltipTest.CustomItemWithTooltip
,DebugStickItem
,DiggerItem
,DiscFragmentItem
,DoubleHighBlockItem
,DyeableArmorItem
,DyeableHorseArmorItem
,DyeItem
,EggItem
,ElytraItem
,EmptyMapItem
,EnchantedBookItem
,EnchantedGoldenAppleItem
,EndCrystalItem
,EnderEyeItem
,EnderpearlItem
,ExperienceBottleItem
,FireChargeItem
,FireworkRocketItem
,FireworkStarItem
,FishingRodItem
,FlintAndSteelItem
,FoodOnAStickItem
,ForgeSpawnEggItem
,GameMasterBlockItem
,GlowInkSacItem
,GravityAttributeTest.ItemGravityStick
,HangingEntityItem
,HangingSignItem
,HiddenTooltipPartsTest.TestItem
,HoeItem
,HoneyBottleItem
,HoneycombItem
,HorseArmorItem
,InkSacItem
,InstrumentItem
,Item
,ItemFluidContainer
,ItemFrameItem
,ItemNameBlockItem
,ItemUseAnimationTest.ThingItem
,KnowledgeBookItem
,LeadItem
,LingeringPotionItem
,MapItem
,MilkBucketItem
,MinecartItem
,MobBucketItem
,NameTagItem
,PickaxeItem
,PlaceOnWaterBlockItem
,PlayerAttackKnockbackTest.KnockbackSwordItem
,PlayerHeadItem
,PotionItem
,ProjectileWeaponItem
,RecordItem
,SaddleItem
,ScaffoldingBlockItem
,ShearsItem
,ShieldItem
,ShovelItem
,SignItem
,SimpleFoiledItem
,SmithingTemplateItem
,SnowballItem
,SolidBucketItem
,SpawnEggItem
,SpectralArrowItem
,SplashPotionItem
,SpyglassItem
,StandingAndWallBlockItem
,StopUsingItemTest.InvertedTelescope
,SuspiciousStewItem
,SwordItem
,ThrowablePotionItem
,TieredItem
,TippedArrowItem
,TridentItem
,WritableBookItem
,WrittenBookItem
public interface IForgeItem
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
canApplyAtEnchantingTable
(ItemStack stack, Enchantment enchantment) Checks whether an item can be enchanted with a certain enchantment.default boolean
canContinueUsing
(ItemStack oldStack, ItemStack newStack) Called while an item is in 'active' use to determine if usage should continue.default boolean
canDisableShield
(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) Can this Item disable a shielddefault boolean
canElytraFly
(ItemStack stack, LivingEntity entity) Used to determine if the player can use Elytra flight.default boolean
canEquip
(ItemStack stack, EquipmentSlot armorType, Entity entity) Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.default boolean
canGrindstoneRepair
(ItemStack stack) Returns true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments.default boolean
canPerformAction
(ItemStack stack, ToolAction toolAction) Queries if an item can perform the given action.default boolean
canWalkOnPowderedSnow
(ItemStack stack, LivingEntity wearer) Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots.default @Nullable Entity
createEntity
(Level level, Entity location, ItemStack stack) This function should return a new entity to replace the dropped item.default <T extends LivingEntity>
intdamageItem
(ItemStack stack, int amount, T entity, Consumer<T> onBroken) Reduce the durability of this item by the amount given.default boolean
doesSneakBypassUse
(ItemStack stack, LevelReader level, BlockPos pos, Player player) Should this item, when held, allow sneak-clicks to pass through to the underlying block?default boolean
elytraFlightTick
(ItemStack stack, LivingEntity entity, int flightTicks) Used to determine if the player can continue Elytra flight, this is called each tick, and can be used to apply ItemStack damage, consume Energy, or what have you.default Map<Enchantment,
Integer> getAllEnchantments
(ItemStack stack) Gets a map of all enchantments present on the stack.default @Nullable String
getArmorTexture
(ItemStack stack, Entity entity, EquipmentSlot slot, String type) Called by RenderBiped and RenderPlayer to determine the armor texture that should be use for the currently equipped item.default com.google.common.collect.Multimap<Attribute,
AttributeModifier> getAttributeModifiers
(EquipmentSlot slot, ItemStack stack) ItemStack sensitive version of getItemAttributeModifiersdefault int
getBurnTime
(ItemStack itemStack, @Nullable RecipeType<?> recipeType) default ItemStack
getCraftingRemainingItem
(ItemStack itemStack) ItemStack sensitive version ofItem.getCraftingRemainingItem()
.default @Nullable String
getCreatorModId
(ItemStack itemStack) Called to get the Mod ID of the mod that *created* the ItemStack, instead of the real Mod ID that *registered* it.default int
Return the itemDamage represented by this ItemStack.default int
getDefaultTooltipHideFlags
(@NotNull ItemStack stack) Get the tooltip parts that should be hidden by default on the given stack if theHideFlags
tag is not set.default int
getEnchantmentLevel
(ItemStack stack, Enchantment enchantment) Gets the level of the enchantment currently present on the stack.default int
getEnchantmentValue
(ItemStack stack) ItemStack sensitive version ofItem.getEnchantmentValue()
.default int
getEntityLifespan
(ItemStack itemStack, Level level) Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.default @Nullable EquipmentSlot
getEquipmentSlot
(ItemStack stack) Override this to set a non-default armor slot for an ItemStack, but do not use this to get the armor slot of said stack; for that, useLivingEntity.getEquipmentSlotForItem(ItemStack)
..default @Nullable FoodProperties
getFoodProperties
(ItemStack stack, @Nullable LivingEntity entity) Get the food properties for this item.default Component
getHighlightTip
(ItemStack item, Component displayName) Allow the item one last chance to modify its name used for the tool highlight useful for adding something extra that can't be removed by a user in the displayed name, such as a mode of operation.default int
getMaxDamage
(ItemStack stack) Return the maxDamage for this ItemStack.default int
getMaxStackSize
(ItemStack stack) Gets the maximum number of items that this stack should be able to hold.default @Nullable CompoundTag
getShareTag
(ItemStack stack) Override this method to change the NBT data being sent to the client.default @NotNull AABB
getSweepHitBox
(@NotNull ItemStack stack, @NotNull Player player, @NotNull Entity target) Get a bounding box (AABB
) of a sweep attack.default float
getXpRepairRatio
(ItemStack stack) Determines the amount of durability the mending enchantment will repair, on average, per point of experience.default boolean
ItemStack sensitive version ofItem.hasCraftingRemainingItem()
.default boolean
hasCustomEntity
(ItemStack stack) Determines if this Item has a special entity for when they are in the world.default ICapabilityProvider
initCapabilities
(ItemStack stack, @Nullable CompoundTag nbt) Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.default boolean
isBookEnchantable
(ItemStack stack, ItemStack book) Allow or forbid the specific book/item combination as an anvil enchantdefault boolean
isCorrectToolForDrops
(ItemStack stack, BlockState state) ItemStack sensitive version ofItem.isCorrectToolForDrops(BlockState)
default boolean
isDamageable
(ItemStack stack) Used to test if this item can be damaged, but with the ItemStack in question.default boolean
Return if this itemstack is damaged.default boolean
isEnderMask
(ItemStack stack, Player player, EnderMan endermanEntity) Whether this Item can be used to hide player head for enderman.default boolean
isNotReplaceableByPickAction
(ItemStack stack, Player player, int inventorySlot) Whether the given ItemStack should be excluded (if possible) when selecting the target hotbar slot of a "pick" action.default boolean
isPiglinCurrency
(ItemStack stack) Called by Piglins when checking to see if they will give an item or something in exchange for this item.boolean
isRepairable
(ItemStack stack) Called by CraftingManager to determine if an item is reparable.default boolean
makesPiglinsNeutral
(ItemStack stack, LivingEntity wearer) Called by Piglins to check if a given item prevents hostility on sight.default void
onArmorTick
(ItemStack stack, Level level, Player player) Deprecated, for removal: This API element is subject to removal in a future version.default boolean
onBlockStartBreak
(ItemStack itemstack, BlockPos pos, Player player) Called before a block is broken.default void
onDestroyed
(ItemEntity itemEntity, DamageSource damageSource) Called when an item entity for this stack is destroyed.default boolean
onDroppedByPlayer
(ItemStack item, Player player) Called when a player drops the item into the world, returning false from this will prevent the item from being removed from the players inventory and spawning in the worlddefault boolean
onEntityItemUpdate
(ItemStack stack, ItemEntity entity) Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner control over the update of the item without having to write a subclass.default boolean
onEntitySwing
(ItemStack stack, LivingEntity entity) Called when a entity tries to play the 'swing' animation.default void
onHorseArmorTick
(ItemStack stack, Level level, Mob horse) Called every tick fromHorse#playGallopSound(SoundEvent)
on the item in the armor slot.default void
onInventoryTick
(ItemStack stack, Level level, Player player, int slotIndex, int selectedIndex) Called to tick this items in a players inventory, the indexes are the global slot index.default InteractionResult
onItemUseFirst
(ItemStack stack, UseOnContext context) This is called when the item is used, before the block is activated.default boolean
onLeftClickEntity
(ItemStack stack, Player player, Entity entity) Called when the player Left Clicks (attacks) an entity.default void
onStopUsing
(ItemStack stack, LivingEntity entity, int count) Called when an entity stops using an item for any reason, notably when selecting another item without releasing or finishing.default void
readShareTag
(ItemStack stack, @Nullable CompoundTag nbt) Override this method to decide what to do with the NBT data received from getNBTShareTag().private Item
self()
default void
Set the damage for this itemstack.default boolean
shouldCauseBlockBreakReset
(ItemStack oldStack, ItemStack newStack) Called when the player is mining a block and the item in his hand changes.default boolean
shouldCauseReequipAnimation
(ItemStack oldStack, ItemStack newStack, boolean slotChanged) Determine if the player switching between these two item stacks
-
Method Details
-
self
-
getAttributeModifiers
default com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(EquipmentSlot slot, ItemStack stack) ItemStack sensitive version of getItemAttributeModifiers -
onDroppedByPlayer
Called when a player drops the item into the world, returning false from this will prevent the item from being removed from the players inventory and spawning in the world- Parameters:
player
- The player that dropped the itemitem
- The item stack, before the item is removed.
-
getHighlightTip
Allow the item one last chance to modify its name used for the tool highlight useful for adding something extra that can't be removed by a user in the displayed name, such as a mode of operation.- Parameters:
item
- the ItemStack for the item.displayName
- the name that will be displayed unless it is changed in this method.
-
onItemUseFirst
This is called when the item is used, before the block is activated.- Returns:
- Return PASS to allow vanilla handling, any other to skip normal code.
-
isPiglinCurrency
Called by Piglins when checking to see if they will give an item or something in exchange for this item.- Returns:
- True if this item can be used as "currency" by piglins
-
makesPiglinsNeutral
Called by Piglins to check if a given item prevents hostility on sight. If this is true the Piglins will be neutral to the entity wearing this item, and will not attack on sight. Note: This does not prevent Piglins from becoming hostile due to other actions, nor does it make Piglins that are already hostile stop being so.- Parameters:
wearer
- The entity wearing this ItemStack- Returns:
- True if piglins are neutral to players wearing this item in an armor slot
-
isRepairable
Called by CraftingManager to determine if an item is reparable.- Returns:
- True if reparable
-
getXpRepairRatio
Determines the amount of durability the mending enchantment will repair, on average, per point of experience. -
onBlockStartBreak
Called before a block is broken. Return true to prevent default block harvesting. Note: In SMP, this is called on both client and server sides!- Parameters:
itemstack
- The current ItemStackpos
- Block's position in worldplayer
- The Player that is wielding the item- Returns:
- True to prevent harvesting, false to continue as normal
-
onStopUsing
Called when an entity stops using an item for any reason, notably when selecting another item without releasing or finishing. This method is called in addition to any other hooks called when an item is finished using; when another hook is also called it will be called before this method. Note that if you break an item while using it (that is, it becomes empty without swapping the stack instance), this hook may not be called on the serverside as you are technically still using the empty item (thus this hook is called on air instead). It is necessary to callLivingEntity.stopUsingItem()
as part of yourItemStack.hurtAndBreak(int, LivingEntity, Consumer)
callback to prevent this issue. For most uses, you likely want one of the following:Item.finishUsingItem(ItemStack, Level, LivingEntity)
for when the player releases and enough ticks have passedItem.releaseUsing(ItemStack, Level, LivingEntity, int)
(ItemStack, Level, LivingEntity)} for when the player releases but the full timer has not passed
- Parameters:
stack
- The Item being usedentity
- The entity using the item, typically a playercount
- The amount of time in tick the item has been used for continuously
-
onLeftClickEntity
Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if return value is true further processing is canceled and the entity is not attacked.- Parameters:
stack
- The Item being usedplayer
- The player that is attackingentity
- The entity being attacked- Returns:
- True to cancel the rest of the interaction.
-
getCraftingRemainingItem
ItemStack sensitive version ofItem.getCraftingRemainingItem()
. Returns a full ItemStack instance of the result.- Parameters:
itemStack
- The current ItemStack- Returns:
- The resulting ItemStack
-
hasCraftingRemainingItem
ItemStack sensitive version ofItem.hasCraftingRemainingItem()
.- Parameters:
stack
- The current item stack- Returns:
- True if this item has a crafting remaining item
-
getEntityLifespan
Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem. This is in ticks, standard result is 6000, or 5 mins.- Parameters:
itemStack
- The current ItemStacklevel
- The level the entity is in- Returns:
- The normal lifespan in ticks.
-
hasCustomEntity
Determines if this Item has a special entity for when they are in the world. Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.- Parameters:
stack
- The current item stack- Returns:
- True of the item has a custom entity, If true, Item#createCustomEntity will be called
-
createEntity
This function should return a new entity to replace the dropped item. Returning null here will not kill the EntityItem and will leave it to function normally. Called when the item it placed in a level.- Parameters:
level
- The level objectlocation
- The EntityItem object, useful for getting the position of the entitystack
- The current item stack- Returns:
- A new Entity object to spawn or null
-
onEntityItemUpdate
Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner control over the update of the item without having to write a subclass.- Parameters:
entity
- The entity Item- Returns:
- Return true to skip any further update code.
-
doesSneakBypassUse
Should this item, when held, allow sneak-clicks to pass through to the underlying block?- Parameters:
level
- The levelpos
- Block position in levelplayer
- The Player that is wielding the item
-
onArmorTick
@Deprecated(forRemoval=true, since="1.20.1") default void onArmorTick(ItemStack stack, Level level, Player player) Deprecated, for removal: This API element is subject to removal in a future version.Called to tick armor in the armor slot. Override to do something -
onInventoryTick
default void onInventoryTick(ItemStack stack, Level level, Player player, int slotIndex, int selectedIndex) Called to tick this items in a players inventory, the indexes are the global slot index. -
canEquip
Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.- Parameters:
stack
- The ItemStackarmorType
- Armor slot to be verified.entity
- The entity trying to equip the armor- Returns:
- True if the given ItemStack can be inserted in the slot
-
getEquipmentSlot
Override this to set a non-default armor slot for an ItemStack, but do not use this to get the armor slot of said stack; for that, useLivingEntity.getEquipmentSlotForItem(ItemStack)
..- Parameters:
stack
- the ItemStack- Returns:
- the armor slot of the ItemStack, or
null
to let the default vanilla logic as perLivingEntity.getSlotForItemStack(stack)
decide
-
isBookEnchantable
Allow or forbid the specific book/item combination as an anvil enchant- Parameters:
stack
- The itembook
- The book- Returns:
- if the enchantment is allowed
-
getArmorTexture
@Nullable default @Nullable String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) Called by RenderBiped and RenderPlayer to determine the armor texture that should be use for the currently equipped item. This will only be called on instances of ItemArmor. Returning null from this function will use the default value.- Parameters:
stack
- ItemStack for the equipped armorentity
- The entity wearing the armorslot
- The slot the armor is intype
- The subtype, can be null or "overlay"- Returns:
- Path of texture to bind, or null to use default
-
onEntitySwing
Called when a entity tries to play the 'swing' animation.- Parameters:
entity
- The entity swinging the item.- Returns:
- True to cancel any further processing by EntityLiving
-
getDamage
Return the itemDamage represented by this ItemStack. Defaults to the Damage entry in the stack NBT, but can be overridden here for other sources.- Parameters:
stack
- The itemstack that is damaged- Returns:
- the damage value
-
getMaxDamage
Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item, but can be overridden here for other sources such as NBT.- Parameters:
stack
- The itemstack that is damaged- Returns:
- the damage value
-
isDamaged
Return if this itemstack is damaged. Note only called ifItemStack.isDamageableItem()
is true.- Parameters:
stack
- the stack- Returns:
- if the stack is damaged
-
setDamage
Set the damage for this itemstack. Note, this method is responsible for zero checking.- Parameters:
stack
- the stackdamage
- the new damage value
-
canPerformAction
Queries if an item can perform the given action. SeeToolActions
for a description of each stock action- Parameters:
stack
- The stack being usedtoolAction
- The action being queried- Returns:
- True if the stack can perform the action
-
isCorrectToolForDrops
ItemStack sensitive version ofItem.isCorrectToolForDrops(BlockState)
- Parameters:
stack
- The itemstack used to harvest the blockstate
- The block trying to harvest- Returns:
- true if the stack can harvest the block
-
getMaxStackSize
Gets the maximum number of items that this stack should be able to hold. This is a ItemStack (and thus NBT) sensitive version ofItem.getMaxStackSize()
.- Parameters:
stack
- The ItemStack- Returns:
- The maximum size this item can be stacked to
-
getEnchantmentValue
ItemStack sensitive version ofItem.getEnchantmentValue()
.- Parameters:
stack
- The ItemStack- Returns:
- the enchantment value
-
canApplyAtEnchantingTable
Checks whether an item can be enchanted with a certain enchantment. This applies specifically to enchanting an item in the enchanting table and is called when retrieving the list of possible enchantments for an item. Enchantments may additionally (or exclusively) be doing their own checks inEnchantment.canApplyAtEnchantingTable(ItemStack)
; check the individual implementation for reference. By default this will check if the enchantment type is valid for this item type.- Parameters:
stack
- the item stack to be enchantedenchantment
- the enchantment to be applied- Returns:
- true if the enchantment can be applied to this item
-
getEnchantmentLevel
Gets the level of the enchantment currently present on the stack. By default, returns the enchantment level present in NBT. Most enchantment implementations rely upon this method. For consistency, results of this method should be the same as getting the enchantment fromgetAllEnchantments(ItemStack)
- Parameters:
stack
- the item stack being checkedenchantment
- the enchantment being checked for- Returns:
- Level of the enchantment, or 0 if not present
- See Also:
-
getAllEnchantments
Gets a map of all enchantments present on the stack. By default, returns the enchantments present in NBT. Used in several places in code including armor enchantment hooks. For consistency, any enchantments in the returned map should include the same level ingetEnchantmentLevel(ItemStack, Enchantment)
- Parameters:
stack
- the item stack being checked- Returns:
- Map of all enchantments on the stack, empty if no enchantments are present
- See Also:
-
shouldCauseReequipAnimation
default boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) Determine if the player switching between these two item stacks- Parameters:
oldStack
- The old stack that was equippednewStack
- The new stackslotChanged
- If the current equipped slot was changed, Vanilla does not play the animation if you switch between two slots that hold the exact same item.- Returns:
- True to play the item change animation
-
shouldCauseBlockBreakReset
Called when the player is mining a block and the item in his hand changes. Allows to not reset blockbreaking if only NBT or similar changes.- Parameters:
oldStack
- The old stack that was used for mining. Item in players main handnewStack
- The new stack- Returns:
- True to reset block break progress
-
canContinueUsing
Called while an item is in 'active' use to determine if usage should continue. Allows items to continue being used while sustaining damage, for example.- Parameters:
oldStack
- the previous 'active' stacknewStack
- the stack currently in the active hand- Returns:
- true to set the new stack to active and continue using it
-
getCreatorModId
Called to get the Mod ID of the mod that *created* the ItemStack, instead of the real Mod ID that *registered* it. For example the Forge Universal Bucket creates a subitem for each modded fluid, and it returns the modded fluid's Mod ID here. Mods that register subitems for other mods can override this. Informational mods can call it to show the mod that created the item.- Parameters:
itemStack
- the ItemStack to check- Returns:
- the Mod ID for the ItemStack, or null when there is no specially
associated mod and
IForgeRegistry.getKey(Object)
would return null.
-
initCapabilities
@Nullable default ICapabilityProvider initCapabilities(ItemStack stack, @Nullable @Nullable CompoundTag nbt) Called from ItemStack.setItem, will hold extra data for the life of this ItemStack. Can be retrieved from stack.getCapabilities() The NBT can be null if this is not called from readNBT or if the item the stack is changing FROM is different then this item, or the previous item had no capabilities. This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item. Remember that getItem CAN return null.- Parameters:
stack
- The ItemStacknbt
- NBT of this item serialized, or null.- Returns:
- A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
-
canDisableShield
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) Can this Item disable a shield- Parameters:
stack
- The ItemStackshield
- The shield in questionentity
- The LivingEntity holding the shieldattacker
- The LivingEntity holding the ItemStack- Returns:
- True if this ItemStack can disable the shield in question.
-
getBurnTime
- Returns:
- the fuel burn time for this itemStack in a furnace. Return 0 to make it not act as a fuel. Return -1 to let the default vanilla logic decide.
-
onHorseArmorTick
Called every tick fromHorse#playGallopSound(SoundEvent)
on the item in the armor slot.- Parameters:
stack
- the armor itemstacklevel
- the level the horse is inhorse
- the horse wearing this armor
-
damageItem
default <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) Reduce the durability of this item by the amount given. This can be used to e.g. consume power from NBT before durability.- Parameters:
stack
- The itemstack to damageamount
- The amount to damageentity
- The entity damaging the itemonBroken
- The on-broken callback from vanilla- Returns:
- The amount of damage to pass to the vanilla logic
-
onDestroyed
Called when an item entity for this stack is destroyed. Note: TheItemStack
can be retrieved from the item entity.- Parameters:
itemEntity
- The item entity that was destroyed.damageSource
- Damage source that caused the item entity to "die".
-
isEnderMask
Whether this Item can be used to hide player head for enderman.- Parameters:
stack
- the ItemStackplayer
- The player watching the endermanendermanEntity
- The enderman that the player look- Returns:
- true if this Item can be used to hide player head for enderman
-
canElytraFly
Used to determine if the player can use Elytra flight. This is called Client and Server side.- Parameters:
stack
- The ItemStack in the Chest slot of the entity.entity
- The entity trying to fly.- Returns:
- True if the entity can use Elytra flight.
-
elytraFlightTick
Used to determine if the player can continue Elytra flight, this is called each tick, and can be used to apply ItemStack damage, consume Energy, or what have you. For example the Vanilla implementation of this, applies damage to the ItemStack every 20 ticks.- Parameters:
stack
- ItemStack in the Chest slot of the entity.entity
- The entity currently in Elytra flight.flightTicks
- The number of ticks the entity has been Elytra flying for.- Returns:
- True if the entity should continue Elytra flight or False to stop.
-
canWalkOnPowderedSnow
Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots. Only affects items worn in the boots slot.- Parameters:
stack
- Stack instancewearer
- The entity wearing this ItemStack- Returns:
- True if the entity can walk on powdered snow
-
isDamageable
Used to test if this item can be damaged, but with the ItemStack in question. Please note that in some cases no ItemStack is available, so the stack-less method will be used.- Parameters:
stack
- ItemStack in the Chest slot of the entity.
-
getSweepHitBox
@NotNull default @NotNull AABB getSweepHitBox(@NotNull @NotNull ItemStack stack, @NotNull @NotNull Player player, @NotNull @NotNull Entity target) Get a bounding box (AABB
) of a sweep attack.- Parameters:
stack
- the stack held by the player.player
- the performing the attack the attack.target
- the entity targeted by the attack.- Returns:
- the bounding box.
-
getDefaultTooltipHideFlags
Get the tooltip parts that should be hidden by default on the given stack if theHideFlags
tag is not set.- Parameters:
stack
- the stack- Returns:
- the default hide flags
- See Also:
-
getFoodProperties
@Nullable default @Nullable FoodProperties getFoodProperties(ItemStack stack, @Nullable @Nullable LivingEntity entity) Get the food properties for this item. Use this instead of theItem.getFoodProperties()
method, for ItemStack sensitivity. The @Nullable annotation was only added, due to the default method, also being @Nullable. Use this with a grain of salt, as if you return null here and true atItem.isEdible()
, NPEs will occur!- Parameters:
stack
- The ItemStack the entity wants to eat.entity
- The entity which wants to eat the food. Be aware that this can be null!- Returns:
- The current FoodProperties for the item.
-
isNotReplaceableByPickAction
Whether the given ItemStack should be excluded (if possible) when selecting the target hotbar slot of a "pick" action. By default, this returns true for enchanted stacks.- Parameters:
player
- the player performing the pickinginventorySlot
- the inventory slot of the item being up for replacement- Returns:
- true to leave this stack in the hotbar if possible
- See Also:
-
canGrindstoneRepair
Returns true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments.- Returns:
- true if the given ItemStack can be put into a grindstone to be repaired and/or stripped of its enchantments
-