Package net.minecraft.item
Class WrittenBookItem
java.lang.Object
net.minecraft.item.Item
net.minecraft.item.WrittenBookItem
- All Implemented Interfaces:
ItemConvertible
public class WrittenBookItem extends Item
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.item.Item
Item.Settings
-
Field Summary
Fields inherited from class net.minecraft.item.Item
ATTACK_DAMAGE_MODIFIER_ID, ATTACK_SPEED_MODIFIER_ID, BLOCK_ITEMS, group, RANDOM
-
Constructor Summary
Constructors Constructor Description WrittenBookItem(Item.Settings settings)
-
Method Summary
Modifier and Type Method Description void
appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context)
static int
getGeneration(ItemStack stack)
Text
getName(ItemStack stack)
static int
getPageCount(ItemStack stack)
boolean
hasGlint(ItemStack stack)
Checks if the glint effect should be applied when the item is rendered.static boolean
isValid(CompoundTag tag)
static boolean
resolve(ItemStack book, ServerCommandSource commandSource, PlayerEntity player)
TypedActionResult<ItemStack>
use(World world, PlayerEntity user, Hand hand)
Called when an item is used by a player.ActionResult
useOnBlock(ItemUsageContext context)
Called when an item is used on a block.Methods inherited from class net.minecraft.item.Item
appendStacks, asItem, byRawId, canMine, canRepair, damage, finishUsing, fromBlock, getAttributeModifiers, getDefaultStack, getDrinkSound, getEatSound, getEnchantability, getFoodComponent, getGroup, getMaxCount, getMaxDamage, getMaxUseTime, getMiningSpeedMultiplier, getName, getOrCreateTranslationKey, getRarity, getRawId, getRecipeRemainder, getTranslationKey, getTranslationKey, getUseAction, hasRecipeRemainder, inventoryTick, isDamageable, isEffectiveOn, isEnchantable, isFireproof, isFood, isIn, isIn, isNetworkSynced, isUsedOnRelease, onCraft, onStoppedUsing, postHit, postMine, postProcessTag, raycast, shouldSyncTagToClient, toString, usageTick, useOnEntity
-
Constructor Details
-
WrittenBookItem
-
-
Method Details
-
isValid
-
getGeneration
-
getPageCount
-
getName
-
appendTooltip
@Environment(CLIENT) public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context)- Overrides:
appendTooltip
in classItem
-
useOnBlock
Called when an item is used on a block.This method is called on both the logical client and logical server, so take caution when using this method. The logical side can be checked using
context.getWorld().isClient()
.- Overrides:
useOnBlock
in classItem
- Parameters:
context
- the usage context- Returns:
- an action result that specifies if using the item on a block was successful.
-
use
Called when an item is used by a player. The use action, by default, is bound to the right mouse button.This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using
world.isClient()
.- Overrides:
use
in classItem
- Parameters:
world
- the world the item was used inuser
- the player who used the itemhand
- the hand used- Returns:
- a typed action result that specifies whether using the item was successful. The action result contains the new item stack that the player's hand will be set to.
-
resolve
public static boolean resolve(ItemStack book, @Nullable ServerCommandSource commandSource, @Nullable PlayerEntity player) -
hasGlint
Checks if the glint effect should be applied when the item is rendered.By default, returns true if the item has enchantments.
-