public interface IForgeItem
Modifier and Type | Method and Description |
---|---|
default 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 shield
|
default boolean |
canElytraFly(ItemStack stack,
LivingEntity entity)
Used to determine if the player can use Elytra flight.
|
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.
|
default boolean |
canHarvestBlock(ItemStack stack,
BlockState state)
ItemStack sensitive version of
#canHarvestBlock(IBlockState) |
default Entity |
createEntity(World world,
Entity location,
ItemStack itemstack)
This function should return a new entity to replace the dropped item.
|
default <T extends LivingEntity> |
damageItem(ItemStack stack,
int amount,
T entity,
java.util.function.Consumer<T> onBroken)
Reduce the durability of this item by the amount given.
|
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?
|
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 com.google.common.collect.ImmutableMap<java.lang.String,ITimeValue> |
getAnimationParameters(ItemStack stack,
World world,
LivingEntity entity) |
default <A extends BipedModel<?>> |
getArmorModel(LivingEntity entityLiving,
ItemStack itemStack,
EquipmentSlotType armorSlot,
A _default)
Override this method to have an item handle its own armor rendering.
|
default java.lang.String |
getArmorTexture(ItemStack stack,
Entity entity,
EquipmentSlotType slot,
java.lang.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<java.lang.String,AttributeModifier> |
getAttributeModifiers(EquipmentSlotType slot,
ItemStack stack)
ItemStack sensitive version of getItemAttributeModifiers
|
default int |
getBurnTime(ItemStack itemStack) |
default ItemStack |
getContainerItem(ItemStack itemStack)
ItemStack sensitive version of getContainerItem.
|
default java.util.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.
|
default java.lang.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 |
getDamage(ItemStack stack)
Return the itemDamage represented by this ItemStack.
|
default double |
getDurabilityForDisplay(ItemStack stack)
Queries the percentage of the 'Durability' bar that should be drawn.
|
default int |
getEntityLifespan(ItemStack itemStack,
World world)
Retrieves the normal 'lifespan' of this item when it is dropped on the ground
as a EntityItem.
|
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.EntityLiving#getSlotForItemStack(ItemStack) . |
default FontRenderer |
getFontRenderer(ItemStack stack)
Returns the font renderer used to render tooltips and overlays for this item.
|
int |
getHarvestLevel(ItemStack stack,
ToolType tool,
PlayerEntity player,
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
|
default java.lang.String |
getHighlightTip(ItemStack item,
java.lang.String 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 Item |
getItem() |
default int |
getItemEnchantability(ItemStack stack)
ItemStack sensitive version of getItemEnchantability
|
default int |
getItemStackLimit(ItemStack stack)
Gets the maximum number of items that this stack should be able to hold.
|
ItemStackTileEntityRenderer |
getItemStackTileEntityRenderer() |
default int |
getMaxDamage(ItemStack stack)
Return the maxDamage for this ItemStack.
|
default int |
getRGBDurabilityForDisplay(ItemStack stack)
Returns the packed int RGB value used to render the durability bar in the
GUI.
|
default CompoundNBT |
getShareTag(ItemStack stack)
Override this method to change the NBT data being sent to the client.
|
default float |
getSmeltingExperience(ItemStack item)
Determines the base experience for a player when they remove this item from a
furnace slot.
|
java.util.Set<ResourceLocation> |
getTags()
Retrieves a list of tags names this is known to be associated with.
|
java.util.Set<ToolType> |
getToolTypes(ItemStack stack) |
default float |
getXpRepairRatio(ItemStack stack)
Determines the amount of durability the mending enchantment
will repair, on average, per point of experience.
|
default boolean |
hasContainerItem(ItemStack stack)
ItemStack sensitive version of hasContainerItem
|
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,
CompoundNBT nbt)
Called from ItemStack.setItem, will hold extra data for the life of this
ItemStack.
|
default boolean |
isBeaconPayment(ItemStack stack)
Whether this Item can be used as a payment to activate the vanilla beacon.
|
default boolean |
isBookEnchantable(ItemStack stack,
ItemStack book)
Allow or forbid the specific book/item combination as an anvil enchant
|
default boolean |
isDamaged(ItemStack stack)
Return if this itemstack is damaged.
|
boolean |
isRepairable(ItemStack stack)
Called by CraftingManager to determine if an item is reparable.
|
default boolean |
isShield(ItemStack stack,
LivingEntity entity)
Is this Item a shield
|
default void |
onArmorTick(ItemStack stack,
World world,
PlayerEntity player)
Called to tick armor in the armor slot.
|
default boolean |
onBlockStartBreak(ItemStack itemstack,
BlockPos pos,
PlayerEntity player)
Called before a block is broken.
|
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
|
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.
|
default boolean |
onEntitySwing(ItemStack stack,
LivingEntity entity)
Called when a entity tries to play the 'swing' animation.
|
default void |
onHorseArmorTick(ItemStack stack,
World world,
MobEntity horse)
Called every tick from
EntityHorse#onUpdate() on the item in the
armor slot. |
default ActionResultType |
onItemUseFirst(ItemStack stack,
ItemUseContext context)
This is called when the item is used, before the block is activated.
|
default boolean |
onLeftClickEntity(ItemStack stack,
PlayerEntity player,
Entity entity)
Called when the player Left Clicks (attacks) an entity.
|
default void |
onUsingTick(ItemStack stack,
LivingEntity player,
int count)
Called each tick while using an item.
|
default void |
readShareTag(ItemStack stack,
CompoundNBT nbt)
Override this method to decide what to do with the NBT data received from
getNBTShareTag().
|
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.
|
default void |
setDamage(ItemStack stack,
int damage)
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
|
default boolean |
showDurabilityBar(ItemStack stack)
Determines if the durability bar should be rendered for this item.
|
default Item getItem()
default com.google.common.collect.Multimap<java.lang.String,AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
default boolean onDroppedByPlayer(ItemStack item, PlayerEntity player)
player
- The player that dropped the itemitem
- The item stack, before the item is removed.default java.lang.String getHighlightTip(ItemStack item, java.lang.String displayName)
item
- the ItemStack for the item.displayName
- the name that will be displayed unless it is changed in
this method.default ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
boolean isRepairable(ItemStack stack)
default float getXpRepairRatio(ItemStack stack)
@Nullable default CompoundNBT getShareTag(ItemStack stack)
stack
- The stack to send the NBT tag fordefault void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt)
stack
- The stack that received NBTnbt
- Received NBT, can be nulldefault boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player)
itemstack
- The current ItemStackpos
- Block's position in worldplayer
- The Player that is wielding the itemdefault void onUsingTick(ItemStack stack, LivingEntity player, int count)
stack
- The Item being usedplayer
- The Player using the itemcount
- The amount of time in tick the item has been used for
continuouslydefault boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity)
stack
- The Item being usedplayer
- The player that is attackingentity
- The entity being attackeddefault ItemStack getContainerItem(ItemStack itemStack)
itemStack
- The current ItemStackdefault boolean hasContainerItem(ItemStack stack)
stack
- The current item stackdefault int getEntityLifespan(ItemStack itemStack, World world)
itemStack
- The current ItemStackworld
- The world the entity is indefault boolean hasCustomEntity(ItemStack stack)
stack
- The current item stack@Nullable default Entity createEntity(World world, Entity location, ItemStack itemstack)
world
- The world objectlocation
- The EntityItem object, useful for getting the position of
the entityitemstack
- The current item stackdefault boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity)
entity
- The entity Itemdefault java.util.Collection<ItemGroup> getCreativeTabs()
default float getSmeltingExperience(ItemStack item)
item
- The item stack the player is picking up.default boolean doesSneakBypassUse(ItemStack stack, IWorldReader world, BlockPos pos, PlayerEntity player)
world
- The worldpos
- Block position in worldplayer
- The Player that is wielding the itemdefault void onArmorTick(ItemStack stack, World world, PlayerEntity player)
default boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
stack
- The ItemStackarmorType
- Armor slot to be verified.entity
- The entity trying to equip the armor@Nullable default EquipmentSlotType getEquipmentSlot(ItemStack stack)
net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)
.stack
- the ItemStacknull
to let the default
vanilla logic as per EntityLiving.getSlotForItemStack(stack)
decidedefault boolean isBookEnchantable(ItemStack stack, ItemStack book)
stack
- The itembook
- The book@Nullable default java.lang.String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, java.lang.String type)
stack
- ItemStack for the equipped armorentity
- The entity wearing the armorslot
- The slot the armor is intype
- The subtype, can be null or "overlay"@Nullable default FontRenderer getFontRenderer(ItemStack stack)
stack
- The current item stack@Nullable default <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A _default)
entityLiving
- The entity wearing the armoritemStack
- The itemStack to render the model ofarmorSlot
- The slot the armor is in_default
- Original armor model. Will have attributes set.default boolean onEntitySwing(ItemStack stack, LivingEntity entity)
entity
- The entity swinging the item.default void renderHelmetOverlay(ItemStack stack, PlayerEntity player, int width, int height, float partialTicks)
stack
- The ItemStack that is equippedplayer
- Reference to the current client entityresolution
- Resolution information about the current viewport and
configured GUI ScalepartialTicks
- Partial ticks for the renderer, useful for interpolationdefault int getDamage(ItemStack stack)
stack
- The itemstack that is damageddefault boolean showDurabilityBar(ItemStack stack)
stack
- The current Item Stackdefault double getDurabilityForDisplay(ItemStack stack)
stack
- The current ItemStackdefault int getRGBDurabilityForDisplay(ItemStack stack)
getDurabilityForDisplay(net.minecraft.item.ItemStack)
, but can be overriden.stack
- Stack to get durability fromdefault int getMaxDamage(ItemStack stack)
stack
- The itemstack that is damageddefault boolean isDamaged(ItemStack stack)
#isDamageable()
is true.stack
- the stackdefault void setDamage(ItemStack stack, int damage)
stack
- the stackdamage
- the new damage valuedefault boolean canHarvestBlock(ItemStack stack, BlockState state)
#canHarvestBlock(IBlockState)
stack
- The itemstack used to harvest the blockstate
- The block trying to harvestdefault int getItemStackLimit(ItemStack stack)
stack
- The ItemStackint getHarvestLevel(ItemStack stack, ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState)
stack
- This item stack instancetoolClass
- Tool Classplayer
- The player trying to harvest the given blockstateblockState
- The block to harvestdefault int getItemEnchantability(ItemStack stack)
stack
- The ItemStackdefault boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
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 enchantedenchantment
- the enchantment to be applieddefault boolean isBeaconPayment(ItemStack stack)
stack
- the ItemStackdefault boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
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.default boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
oldStack
- The old stack that was used for mining. Item in players main
handnewStack
- The new stackdefault boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
oldStack
- the previous 'active' stacknewStack
- the stack currently in the active hand@Nullable default java.lang.String getCreatorModId(ItemStack itemStack)
itemStack
- the ItemStack to check#getRegistryName()
would return null.@Nullable default ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt)
stack
- The ItemStacknbt
- NBT of this item serialized, or null.default com.google.common.collect.ImmutableMap<java.lang.String,ITimeValue> getAnimationParameters(ItemStack stack, World world, LivingEntity entity)
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker)
stack
- The ItemStackshield
- The shield in questionentity
- The EntityLivingBase holding the shieldattacker
- The EntityLivingBase holding the ItemStackdefault boolean isShield(ItemStack stack, @Nullable LivingEntity entity)
stack
- The ItemStackentity
- The Entity holding the ItemStackdefault int getBurnTime(ItemStack itemStack)
default void onHorseArmorTick(ItemStack stack, World world, MobEntity horse)
EntityHorse#onUpdate()
on the item in the
armor slot.stack
- the armor itemstackworld
- the world the horse is inhorse
- the horse wearing this armorItemStackTileEntityRenderer getItemStackTileEntityRenderer()
java.util.Set<ResourceLocation> getTags()
default <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, java.util.function.Consumer<T> onBroken)
stack
- The itemstack to damageamount
- The amount to damageentity
- The entity damaging the itemonBroken
- The on-broken callback from vanilladefault boolean canElytraFly(ItemStack stack, LivingEntity entity)
stack
- The ItemStack in the Chest slot of the entity.entity
- The entity trying to fly.default boolean elytraFlightTick(ItemStack stack, LivingEntity entity, int flightTicks)
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.