Interface IForgeItem

All Known Implementing Classes:
AbstractMapItem, AirItem, ArmorItem, ArmorStandItem, ArrowItem, AxeItem, BannerItem, BannerPatternItem, BedItem, BlockItem, BlockNamedItem, BoatItem, BoneMealItem, BookItem, BowItem, BucketItem, ChorusFruitItem, CompassItem, CrossbowItem, CustomElytraTest.CustomElytra, DebugStickItem, DyeableArmorItem, DyeableHorseArmorItem, DyeItem, EggItem, ElytraItem, EnchantedBookItem, EnchantedGoldenAppleItem, EnderCrystalItem, EnderEyeItem, EnderPearlItem, ExperienceBottleItem, FilledMapItem, FireChargeItem, FireworkRocketItem, FireworkStarItem, FishBucketItem, FishingRodItem, FlintAndSteelItem, ForgeSpawnEggItem, GlassBottleItem, GravityAttributeTest.ItemGravityStick, HangingEntityItem, HoeItem, HoneyBottleItem, HorseArmorItem, Item, ItemFluidContainer, ItemFrameItem, KnowledgeBookItem, LeadItem, LilyPadItem, LingeringPotionItem, MapItem, MilkBucketItem, MinecartItem, MusicDiscItem, NameTagItem, OnAStickItem, OperatorOnlyItem, PickaxeItem, PlayerAttackKnockbackTest.KnockbackSwordItem, PotionItem, SaddleItem, ScaffoldingItem, ShearsItem, ShieldItem, ShootableItem, ShovelItem, SignItem, SimpleFoiledItem, SkullItem, SnowballItem, SoupItem, SpawnEggItem, SpectralArrowItem, SplashPotionItem, SuspiciousStewItem, SwordItem, TallBlockItem, ThrowablePotionItem, TieredItem, TippedArrowItem, ToolItem, TridentItem, WallOrFloorItem, WritableBookItem, WrittenBookItem

public interface IForgeItem
  • Method Details

    • getItem

      default Item getItem()
    • getAttributeModifiers

      default<Attribute,AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
      ItemStack sensitive version of getItemAttributeModifiers
    • onDroppedByPlayer

      default boolean onDroppedByPlayer(ItemStack item, PlayerEntity 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 world
      player - The player that dropped the item
      item - The item stack, before the item is removed.
    • getHighlightTip

      default ITextComponent getHighlightTip(ItemStack item, ITextComponent 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.
      item - the ItemStack for the item.
      displayName - the name that will be displayed unless it is changed in this method.
    • onItemUseFirst

      default ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
      This is called when the item is used, before the block is activated.
      Return PASS to allow vanilla handling, any other to skip normal code.
    • isPiglinCurrency

      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.
      True if this item can be used as "currency" by piglins
    • makesPiglinsNeutral

      default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer)
      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.
      wearer - The entity wearing this ItemStack
      True if piglins are neutral to players wearing this item in an armor slot
    • isRepairable

      boolean isRepairable(ItemStack stack)
      Called by CraftingManager to determine if an item is reparable.
      True if reparable
    • getXpRepairRatio

      default float getXpRepairRatio(ItemStack stack)
      Determines the amount of durability the mending enchantment will repair, on average, per point of experience.
    • getShareTag

      @Nullable default CompoundNBT getShareTag(ItemStack stack)
      Override this method to change the NBT data being sent to the client. You should ONLY override this when you have no other choice, as this might change behavior client side! Note that this will sometimes be applied multiple times, the following MUST be supported: Item item = stack.getItem(); NBTTagCompound nbtShare1 = item.getNBTShareTag(stack); stack.setTagCompound(nbtShare1); NBTTagCompound nbtShare2 = item.getNBTShareTag(stack); assert nbtShare1.equals(nbtShare2);
      stack - The stack to send the NBT tag for
      The NBT tag
    • readShareTag

      default void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt)
      Override this method to decide what to do with the NBT data received from getNBTShareTag().
      stack - The stack that received NBT
      nbt - Received NBT, can be null
    • onBlockStartBreak

      default boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player)
      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!
      itemstack - The current ItemStack
      pos - Block's position in world
      player - The Player that is wielding the item
      True to prevent harvesting, false to continue as normal
    • onUsingTick

      default void onUsingTick(ItemStack stack, LivingEntity player, int count)
      Called each tick while using an item.
      stack - The Item being used
      player - The Player using the item
      count - The amount of time in tick the item has been used for continuously
    • onLeftClickEntity

      default boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity)
      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.
      stack - The Item being used
      player - The player that is attacking
      entity - The entity being attacked
      True to cancel the rest of the interaction.
    • getContainerItem

      default ItemStack getContainerItem(ItemStack itemStack)
      ItemStack sensitive version of getContainerItem. Returns a full ItemStack instance of the result.
      itemStack - The current ItemStack
      The resulting ItemStack
    • hasContainerItem

      default boolean hasContainerItem(ItemStack stack)
      ItemStack sensitive version of hasContainerItem
      stack - The current item stack
      True if this item has a 'container'
    • getEntityLifespan

      default int getEntityLifespan(ItemStack itemStack, World world)
      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.
      itemStack - The current ItemStack
      world - The world the entity is in
      The normal lifespan in ticks.
    • hasCustomEntity

      default boolean hasCustomEntity(ItemStack stack)
      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.
      stack - The current item stack
      True of the item has a custom entity, If true, Item#createCustomEntity will be called
    • createEntity

      @Nullable default Entity createEntity(World world, Entity location, ItemStack itemstack)
      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 world.
      world - The world object
      location - The EntityItem object, useful for getting the position of the entity
      itemstack - The current item stack
      A new Entity object to spawn or null
    • onEntityItemUpdate

      default 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.
      entity - The entity Item
      Return true to skip any further update code.
    • getCreativeTabs

      default Collection<ItemGroup> getCreativeTabs()
      Gets a list of tabs that items belonging to this class can display on, combined properly with getSubItems allows for a single item to span many sub-items across many tabs.
      A list of all tabs that this item could possibly be one.
    • getSmeltingExperience

      default float getSmeltingExperience(ItemStack item)
      Determines the base experience for a player when they remove this item from a furnace slot. This number must be between 0 and 1 for it to be valid. This number will be multiplied by the stack size to get the total experience.
      item - The item stack the player is picking up.
      The amount to award for each item.
    • doesSneakBypassUse

      default boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player)
      Should this item, when held, allow sneak-clicks to pass through to the underlying block?
      world - The world
      pos - Block position in world
      player - The Player that is wielding the item
    • onArmorTick

      default void onArmorTick(ItemStack stack, World world, PlayerEntity player)
      Called to tick armor in the armor slot. Override to do something
    • canEquip

      default boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
      Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.
      stack - The ItemStack
      armorType - Armor slot to be verified.
      entity - The entity trying to equip the armor
      True if the given ItemStack can be inserted in the slot
    • getEquipmentSlot

      @Nullable default EquipmentSlotType 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, use net.minecraft.entity.LivingEntity#getSlotForItemStack(ItemStack).
      stack - the ItemStack
      the armor slot of the ItemStack, or null to let the default vanilla logic as per LivingEntity.getSlotForItemStack(stack) decide
    • isBookEnchantable

      default boolean isBookEnchantable(ItemStack stack, ItemStack book)
      Allow or forbid the specific book/item combination as an anvil enchant
      stack - The item
      book - The book
      if the enchantment is allowed
    • getArmorTexture

      @Nullable default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType 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.
      stack - ItemStack for the equipped armor
      entity - The entity wearing the armor
      slot - The slot the armor is in
      type - The subtype, can be null or "overlay"
      Path of texture to bind, or null to use default
    • getFontRenderer

      @Nullable default FontRenderer getFontRenderer(ItemStack stack)
      Returns the font renderer used to render tooltips and overlays for this item. Returning null will use the standard font renderer.
      stack - The current item stack
      A instance of FontRenderer or null to use default
    • getArmorModel

      @Nullable default <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A _default)
      Override this method to have an item handle its own armor rendering.
      entityLiving - The entity wearing the armor
      itemStack - The itemStack to render the model of
      armorSlot - The slot the armor is in
      _default - Original armor model. Will have attributes set.
      A ModelBiped to render instead of the default
    • onEntitySwing

      default boolean onEntitySwing(ItemStack stack, LivingEntity entity)
      Called when a entity tries to play the 'swing' animation.
      entity - The entity swinging the item.
      True to cancel any further processing by EntityLiving
    • renderHelmetOverlay

      default void renderHelmetOverlay(ItemStack stack, PlayerEntity player, int width, int height, float partialTicks)
      Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet. This is where pumpkins would render there overlay.
      stack - The ItemStack that is equipped
      player - Reference to the current client entity
      resolution - Resolution information about the current viewport and configured GUI Scale
      partialTicks - Partial ticks for the renderer, useful for interpolation
    • getDamage

      default int getDamage(ItemStack stack)
      Return the itemDamage represented by this ItemStack. Defaults to the Damage entry in the stack NBT, but can be overridden here for other sources.
      stack - The itemstack that is damaged
      the damage value
    • showDurabilityBar

      default boolean showDurabilityBar(ItemStack stack)
      Determines if the durability bar should be rendered for this item. Defaults to vanilla stack.isDamaged behavior. But modders can use this for any data they wish.
      stack - The current Item Stack
      True if it should render the 'durability' bar.
    • getDurabilityForDisplay

      default double getDurabilityForDisplay(ItemStack stack)
      Queries the percentage of the 'Durability' bar that should be drawn.
      stack - The current ItemStack
      0.0 for 100% (no damage / full bar), 1.0 for 0% (fully damaged / empty bar)
    • getRGBDurabilityForDisplay

      default int getRGBDurabilityForDisplay(ItemStack stack)
      Returns the packed int RGB value used to render the durability bar in the GUI. Defaults to a value based on the hue scaled based on getDurabilityForDisplay(net.minecraft.item.ItemStack), but can be overriden.
      stack - Stack to get durability from
      A packed RGB value for the durability colour (0x00RRGGBB)
    • getMaxDamage

      default int getMaxDamage(ItemStack stack)
      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.
      stack - The itemstack that is damaged
      the damage value
    • isDamaged

      default boolean isDamaged(ItemStack stack)
      Return if this itemstack is damaged. Note only called if #isDamageable() is true.
      stack - the stack
      if the stack is damaged
    • setDamage

      default void setDamage(ItemStack stack, int damage)
      Set the damage for this itemstack. Note, this method is responsible for zero checking.
      stack - the stack
      damage - the new damage value
    • canHarvestBlock

      default boolean canHarvestBlock(ItemStack stack, BlockState state)
      ItemStack sensitive version of #canHarvestBlock(IBlockState)
      stack - The itemstack used to harvest the block
      state - The block trying to harvest
      true if can harvest the block
    • getItemStackLimit

      default int getItemStackLimit(ItemStack stack)
      Gets the maximum number of items that this stack should be able to hold. This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
      stack - The ItemStack
      The maximum number this item can be stacked to
    • getToolTypes

      Set<ToolType> getToolTypes(ItemStack stack)
    • getHarvestLevel

      int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState)
      Queries the harvest level of this item stack for the specified tool class, Returns -1 if this tool is not of the specified type
      stack - This item stack instance
      toolClass - Tool Class
      player - The player trying to harvest the given blockstate
      blockState - The block to harvest
      Harvest level, or -1 if not the specified tool type.
    • getItemEnchantability

      default int getItemEnchantability(ItemStack stack)
      ItemStack sensitive version of getItemEnchantability
      stack - The ItemStack
      the item echantability value
    • canApplyAtEnchantingTable

      default boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
      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 in Enchantment.canApplyAtEnchantingTable(ItemStack); check the individual implementation for reference. By default this will check if the enchantment type is valid for this item type.
      stack - the item stack to be enchanted
      enchantment - the enchantment to be applied
      true if the enchantment can be applied to this item
    • shouldCauseReequipAnimation

      default boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
      Determine if the player switching between these two item stacks
      oldStack - The old stack that was equipped
      newStack - The new stack
      slotChanged - 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.
      True to play the item change animation
    • shouldCauseBlockBreakReset

      default boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
      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.
      oldStack - The old stack that was used for mining. Item in players main hand
      newStack - The new stack
      True to reset block break progress
    • canContinueUsing

      default boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
      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.
      oldStack - the previous 'active' stack
      newStack - the stack currently in the active hand
      true to set the new stack to active and continue using it
    • getCreatorModId

      @Nullable default 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. 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.
      itemStack - the ItemStack to check
      the Mod ID for the ItemStack, or null when there is no specially associated mod and #getRegistryName() would return null.
    • initCapabilities

      @Nullable default ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT 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.
      stack - The ItemStack
      nbt - NBT of this item serialized, or null.
      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
      stack - The ItemStack
      shield - The shield in question
      entity - The LivingEntity holding the shield
      attacker - The LivingEntity holding the ItemStack
    • isShield

      default boolean isShield(ItemStack stack, @Nullable LivingEntity entity)
      Is this Item a shield
      stack - The ItemStack
      entity - The Entity holding the ItemStack
      True if the ItemStack is considered a shield
    • getBurnTime

      default int getBurnTime(ItemStack itemStack, @Nullable IRecipeType<?> recipeType)
      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.
    • getBurnTime

      @Deprecated default int getBurnTime(ItemStack stack)
    • onHorseArmorTick

      default void onHorseArmorTick(ItemStack stack, World world, MobEntity horse)
      Called every tick from EntityHorse#onUpdate() on the item in the armor slot.
      stack - the armor itemstack
      world - the world the horse is in
      horse - the horse wearing this armor
    • getItemStackTileEntityRenderer

      ItemStackTileEntityRenderer getItemStackTileEntityRenderer()
      This Item's renderer, or the default instance if it does not have one.
    • getTags

      Set<ResourceLocation> getTags()
      Retrieves a list of tags names this is known to be associated with. This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes.
    • 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.
      stack - The itemstack to damage
      amount - The amount to damage
      entity - The entity damaging the item
      onBroken - The on-broken callback from vanilla
      The amount of damage to pass to the vanilla logic
    • isEnderMask

      default boolean isEnderMask(ItemStack stack, PlayerEntity player, EndermanEntity endermanEntity)
      Whether this Item can be used to hide player head for enderman.
      stack - the ItemStack
      player - The player watching the enderman
      endermanEntity - The enderman that the player look
      true if this Item can be used to hide player head for enderman
    • canElytraFly

      default boolean canElytraFly(ItemStack stack, LivingEntity entity)
      Used to determine if the player can use Elytra flight. This is called Client and Server side.
      stack - The ItemStack in the Chest slot of the entity.
      entity - The entity trying to fly.
      True if the entity can use Elytra flight.
    • elytraFlightTick

      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. For example the Vanilla implementation of this, applies damage to the ItemStack every 20 ticks.
      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.
      True if the entity should continue Elytra flight or False to stop.
    • isDamageable

      default boolean isDamageable(ItemStack stack)
      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.
      stack - ItemStack in the Chest slot of the entity.