public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
Modifier and Type | Method and Description |
---|---|
default boolean |
areShareTagsEqual(ItemStack other)
Modeled after ItemStack.areItemStackTagsEqual
Uses Item.getNBTShareTag for comparison instead of NBT and capabilities.
|
default boolean |
canApplyAtEnchantingTable(Enchantment enchantment)
Checks whether an item can be enchanted with a certain enchantment.
|
default boolean |
canDisableShield(ItemStack shield,
LivingEntity entity,
LivingEntity attacker)
Can this Item disable a shield
|
default boolean |
canElytraFly(LivingEntity entity)
Used to determine if the player can use Elytra flight.
|
default boolean |
canEquip(EquipmentSlotType armorType,
Entity entity)
Determines if the specific ItemStack can be placed in the specified armor
slot, for the entity.
|
default boolean |
doesSneakBypassUse(IWorldReader world,
BlockPos pos,
PlayerEntity player)
Should this item, when held, allow sneak-clicks to pass through to the underlying block?
|
default boolean |
elytraFlightTick(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 boolean |
equals(ItemStack other,
boolean limitTags)
Determines if the ItemStack is equal to the other item stack, including Item, Count, and NBT.
|
default int |
getBurnTime() |
default ItemStack |
getContainerItem()
ItemStack sensitive version of getContainerItem.
|
default int |
getEntityLifespan(World world)
Retrieves the normal 'lifespan' of this item when it is dropped on the ground
as a EntityItem.
|
default EquipmentSlotType |
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, use
net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack) . |
default int |
getHarvestLevel(ToolType tool,
PlayerEntity player,
BlockState state)
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(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 int |
getItemEnchantability()
ItemStack sensitive version of getItemEnchantability
|
default CompoundNBT |
getShareTag()
Get the NBT data to be sent to the client.
|
default ItemStack |
getStack() |
default java.util.Set<ToolType> |
getToolTypes() |
default float |
getXpRepairRatio()
Determines the amount of durability the mending enchantment
will repair, on average, per point of experience.
|
default boolean |
hasContainerItem()
ItemStack sensitive version of hasContainerItem
|
default boolean |
isBeaconPayment()
Whether this Item can be used as a payment to activate the vanilla beacon.
|
default boolean |
isBookEnchantable(ItemStack book)
Allow or forbid the specific book/item combination as an anvil enchant
|
default boolean |
isRepairable()
Determines if a item is reparable, used by Repair recipes and Grindstone.
|
default boolean |
isShield(LivingEntity entity)
Is this Item a shield
|
default void |
onArmorTick(World world,
PlayerEntity player)
Called to tick armor in the armor slot.
|
default boolean |
onBlockStartBreak(BlockPos pos,
PlayerEntity player)
Called before a block is broken.
|
default boolean |
onDroppedByPlayer(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(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(LivingEntity entity)
Called when a entity tries to play the 'swing' animation.
|
default void |
onHorseArmorTick(World world,
MobEntity horse)
Called every tick from
EntityHorse#onUpdate() on the item in the
armor slot. |
default ActionResultType |
onItemUseFirst(ItemUseContext context) |
default void |
onUsingTick(LivingEntity player,
int count)
Called each tick while using an item.
|
default void |
readShareTag(CompoundNBT nbt)
Override this method to decide what to do with the NBT data received from
getNBTShareTag().
|
default CompoundNBT |
serializeNBT() |
default boolean |
shouldCauseBlockBreakReset(ItemStack newStack)
Called when the player is mining a block and the item in his hand changes.
|
getCapability, getCapability
deserializeNBT
default ItemStack getStack()
default ItemStack getContainerItem()
itemStack
- The current ItemStackdefault boolean hasContainerItem()
stack
- The current item stackdefault int getBurnTime()
default int getHarvestLevel(ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState state)
stack
- This item stack instancetoolClass
- Tool Classplayer
- The player trying to harvest the given blockstatestate
- The block to harvestdefault java.util.Set<ToolType> getToolTypes()
default ActionResultType onItemUseFirst(ItemUseContext context)
default CompoundNBT serializeNBT()
serializeNBT
in interface INBTSerializable<CompoundNBT>
default boolean onBlockStartBreak(BlockPos pos, PlayerEntity player)
pos
- Block's position in worldplayer
- The Player that is wielding the itemdefault boolean shouldCauseBlockBreakReset(ItemStack newStack)
newStack
- The new stackdefault boolean canApplyAtEnchantingTable(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 int getItemEnchantability()
@Nullable default EquipmentSlotType getEquipmentSlot()
net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)
.null
to let the default
vanilla logic as per EntityLiving.getSlotForItemStack(stack)
decidedefault boolean canDisableShield(ItemStack shield, LivingEntity entity, LivingEntity attacker)
shield
- The shield in questionentity
- The EntityLivingBase holding the shieldattacker
- The EntityLivingBase holding the ItemStackdefault boolean isShield(@Nullable LivingEntity entity)
entity
- The Entity holding the ItemStackdefault boolean onEntitySwing(LivingEntity entity)
entity
- The entity swinging the item.default void onUsingTick(LivingEntity player, int count)
player
- The Player using the itemcount
- The amount of time in tick the item has been used for
continuouslydefault int getEntityLifespan(World world)
world
- The world the entity is indefault boolean onEntityItemUpdate(ItemEntity entity)
entity
- The entity Itemdefault float getXpRepairRatio()
default void onArmorTick(World world, PlayerEntity player)
default void onHorseArmorTick(World world, MobEntity horse)
EntityHorse#onUpdate()
on the item in the
armor slot.world
- the world the horse is inhorse
- the horse wearing this armordefault boolean isBeaconPayment()
default boolean canEquip(EquipmentSlotType armorType, Entity entity)
armorType
- Armor slot to be verified.entity
- The entity trying to equip the armordefault boolean isBookEnchantable(ItemStack book)
stack
- The itembook
- The bookdefault boolean onDroppedByPlayer(PlayerEntity player)
player
- The player that dropped the itemitem
- The item stack, before the item is removed.default java.lang.String getHighlightTip(java.lang.String displayName)
displayName
- the name that will be displayed unless it is changed in
this method.@Nullable default CompoundNBT getShareTag()
default void readShareTag(@Nullable CompoundNBT nbt)
stack
- The stack that received NBTnbt
- Received NBT, can be nulldefault boolean doesSneakBypassUse(IWorldReader world, BlockPos pos, PlayerEntity player)
world
- The worldpos
- Block position in worldplayer
- The Player that is wielding the itemdefault boolean areShareTagsEqual(ItemStack other)
default boolean equals(ItemStack other, boolean limitTags)
other
- The other stacklimitTags
- True to use shareTag False to use full NBT tagdefault boolean isRepairable()
default boolean canElytraFly(LivingEntity entity)
entity
- The entity trying to fly.default boolean elytraFlightTick(LivingEntity entity, int flightTicks)
entity
- The entity currently in Elytra flight.flightTicks
- The number of ticks the entity has been Elytra flying for.