You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.7 KiB
Java
95 lines
2.7 KiB
Java
package net.minecraft.item;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import java.util.List;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
import net.minecraft.util.StatCollector;
|
|
import net.minecraft.util.StringUtils;
|
|
import net.minecraft.world.World;
|
|
|
|
public class ItemEditableBook extends Item
|
|
{
|
|
private static final String __OBFID = "CL_00000077";
|
|
|
|
public ItemEditableBook()
|
|
{
|
|
this.setMaxStackSize(1);
|
|
}
|
|
|
|
public static boolean validBookTagContents(NBTTagCompound p_77828_0_)
|
|
{
|
|
if (!ItemWritableBook.func_150930_a(p_77828_0_))
|
|
{
|
|
return false;
|
|
}
|
|
else if (!p_77828_0_.hasKey("title", 8))
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
String s = p_77828_0_.getString("title");
|
|
return s != null && s.length() <= 16 ? p_77828_0_.hasKey("author", 8) : false;
|
|
}
|
|
}
|
|
|
|
public String getItemStackDisplayName(ItemStack p_77653_1_)
|
|
{
|
|
if (p_77653_1_.hasTagCompound())
|
|
{
|
|
NBTTagCompound nbttagcompound = p_77653_1_.getTagCompound();
|
|
String s = nbttagcompound.getString("title");
|
|
|
|
if (!StringUtils.isNullOrEmpty(s))
|
|
{
|
|
return s;
|
|
}
|
|
}
|
|
|
|
return super.getItemStackDisplayName(p_77653_1_);
|
|
}
|
|
|
|
/**
|
|
* allows items to add custom lines of information to the mouseover description
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_)
|
|
{
|
|
if (p_77624_1_.hasTagCompound())
|
|
{
|
|
NBTTagCompound nbttagcompound = p_77624_1_.getTagCompound();
|
|
String s = nbttagcompound.getString("author");
|
|
|
|
if (!StringUtils.isNullOrEmpty(s))
|
|
{
|
|
p_77624_3_.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
|
*/
|
|
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer player)
|
|
{
|
|
player.displayGUIBook(itemStackIn);
|
|
return itemStackIn;
|
|
}
|
|
|
|
/**
|
|
* If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
|
|
*/
|
|
public boolean getShareTag()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public boolean hasEffect(ItemStack p_77636_1_)
|
|
{
|
|
return true;
|
|
}
|
|
} |