ItemWritableBook .java

net.minecraft.item.ItemWritableBook (class): members: isNBTValid, onItemRightClick. strings: "pages". imports: NBTTagList, StatList, NBTTagCompound.

net.minecraft.itemclass62 linescommonextends Item1.5 KB

API Surface (2)

ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
boolean isNBTValid(NBTTagCompound nbt)

String literals (1)

"pages"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ItemWritableBook.java62 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.entity.player.EntityPlayer;
4
import net.minecraft.nbt.NBTTagCompound;
5
import net.minecraft.nbt.NBTTagList;
6
import net.minecraft.stats.StatList;
7
import net.minecraft.world.World;
8
9
public class ItemWritableBook extends Item
10
{
11
    public ItemWritableBook()
12
    {
13
        this.setMaxStackSize(1);
14
    }
15
16
    /**
17
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
18
     */
19
    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
20
    {
21
        playerIn.displayGUIBook(itemStackIn);
22
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
23
        return itemStackIn;
24
    }
25
26
    /**
27
     * this method returns true if the book's NBT Tag List "pages" is valid
28
     */
29
    public static boolean isNBTValid(NBTTagCompound nbt)
30
    {
31
        if (nbt == null)
32
        {
33
            return false;
34
        }
35
        else if (!nbt.hasKey("pages", 9))
36
        {
37
            return false;
38
        }
39
        else
40
        {
41
            NBTTagList nbttaglist = nbt.getTagList("pages", 8);
42
43
            for (int i = 0; i < nbttaglist.tagCount(); ++i)
44
            {
45
                String s = nbttaglist.getStringTagAt(i);
46
47
                if (s == null)
48
                {
49
                    return false;
50
                }
51
52
                if (s.length() > 32767)
53
                {
54
                    return false;
55
                }
56
            }
57
58
            return true;
59
        }
60
    }
61
}
62

Deobfuscated MCP 1.8.9 source of ItemWritableBook from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemWritableBook.java), stored verbatim.