001 package net.minecraft.src;
002
003 public class ItemWritableBook extends Item
004 {
005 public ItemWritableBook(int par1)
006 {
007 super(par1);
008 this.setMaxStackSize(1);
009 }
010
011 /**
012 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
013 */
014 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
015 {
016 par3EntityPlayer.displayGUIBook(par1ItemStack);
017 return par1ItemStack;
018 }
019
020 /**
021 * If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
022 */
023 public boolean getShareTag()
024 {
025 return true;
026 }
027
028 public static boolean validBookTagPages(NBTTagCompound par0NBTTagCompound)
029 {
030 if (par0NBTTagCompound == null)
031 {
032 return false;
033 }
034 else if (!par0NBTTagCompound.hasKey("pages"))
035 {
036 return false;
037 }
038 else
039 {
040 NBTTagList var1 = (NBTTagList)par0NBTTagCompound.getTag("pages");
041
042 for (int var2 = 0; var2 < var1.tagCount(); ++var2)
043 {
044 NBTTagString var3 = (NBTTagString)var1.tagAt(var2);
045
046 if (var3.data == null)
047 {
048 return false;
049 }
050
051 if (var3.data.length() > 256)
052 {
053 return false;
054 }
055 }
056
057 return true;
058 }
059 }
060 }