Class WrittenBookItem

java.lang.Object
net.minecraft.item.Item
net.minecraft.item.WrittenBookItem
All Implemented Interfaces:
ItemConvertible

public class WrittenBookItem
extends Item
  • Constructor Details

    • WrittenBookItem

      public WrittenBookItem​(Item.Settings settings)
  • Method Details

    • isValid

      public static boolean isValid​(@Nullable CompoundTag tag)
    • getGeneration

      public static int getGeneration​(ItemStack stack)
    • getPageCount

      public static int getPageCount​(ItemStack stack)
    • getName

      public Text getName​(ItemStack stack)
      Overrides:
      getName in class Item
    • appendTooltip

      @Environment(CLIENT) public void appendTooltip​(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context)
      Overrides:
      appendTooltip in class Item
    • useOnBlock

      public ActionResult useOnBlock​(ItemUsageContext context)
      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 class Item
      Parameters:
      context - the usage context
      Returns:
      an action result that specifies if using the item on a block was successful.
    • use

      public TypedActionResult<ItemStack> use​(World world, PlayerEntity user, Hand hand)
      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 class Item
      Parameters:
      world - the world the item was used in
      user - the player who used the item
      hand - 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

      public boolean hasGlint​(ItemStack stack)
      Checks if the glint effect should be applied when the item is rendered.

      By default, returns true if the item has enchantments.

      Overrides:
      hasGlint in class Item