GT5-Unofficial/main/java/gregtech/common/items/behaviors/Behaviour_WrittenBook.java

39 lines
1.4 KiB
Java
Raw Normal View History

2015-06-23 22:29:05 +00:00
package gregtech.common.items.behaviors;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.items.GT_MetaBase_Item;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Utility.ItemNBT;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class Behaviour_WrittenBook
extends Behaviour_None
{
@SideOnly(Side.CLIENT)
public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ)
{
if ((GT_Utility.isStringValid(GT_Utility.ItemNBT.getBookTitle(aStack))) && ((aPlayer instanceof EntityPlayerSP))) {
Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(aPlayer, aStack, false));
}
return true;
}
public List<String> getAdditionalToolTips(GT_MetaBase_Item aItem, List<String> aList, ItemStack aStack)
{
String tTitle = GT_Utility.ItemNBT.getBookTitle(aStack);
if (GT_Utility.isStringValid(tTitle))
{
aList.add(tTitle);
aList.add("by " + GT_Utility.ItemNBT.getBookAuthor(aStack));
}
return aList;
}
}