I am wondering how to add "lore" to an item. If you don't know what lore is, it was added in the same update that added in the customized naming feature. Sethbling had created a filter allowing you to name items (this was in a snapshot before anvils) and there was also a filter for lore (a description below the item). Like I said before, if there is a way to not only access this method, but to integrate it into a item (IE make all items of that type have a specific lore) It would be greatly appreciated.
I understand that for the custom items, but what about existing vanilla ones...
Here's an example...My mod has a crafting recipe for my player head (SkullOwner tag is AvidPenguin)
How would I go about putting, say, purple text underneath "AvidPenguin's head" saying "Anything it doesn't matter"
Look in the ItemStack code where it gets the tooltip display, you'll see:
@Override
public void addInformation(ItemStack istack, EntityPlayer player, List info, boolean par4) {
NBTTagCompound tag = istack.stackTagCompound;
if (tag == null)
{
tag = new NBTTagCompound();
tag.setTag("display", new NBTTagCompound());
istack.stackTagCompound = tag;
}
tag.getTag("display");
tag.setTag("display", new NBTTagCompound());
NBTTagCompound taglore = tag.getCompoundTag("display");
NBTTagList lore = new NBTTagList();
lore.appendTag(new NBTTagString("§r"+"This is a special item, for adding"));
lore.appendTag(new NBTTagString("§r"+"guests"));
lore.appendTag(new NBTTagString("§r"+"into your home."));
taglore.setTag("Lore", lore);
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par2List, boolean par4)
{
par2List.add("\u00a76" + "A legendary sword made from the ashes of the nether.");
par2List.add("\u00a75" + "Found In Sand temples");
}
}
The Meaning of Life, the Universe, and Everything.
Join Date:
11/26/2014
Posts:
43
Minecraft:
DylanHedger
PSN:
DylanHedger
Member Details
i know right if you want you can add a class e.g. (ItemLore) And When You Register the item you can set it to do this |||| ItemLore("A Chicken Nugget") |||
So I don't understand what you mean by this and how to ensure it gets called. I'm trying to add Lore to something, say Emeralds.
I've been trying something like
List<String> emlore= new ArrayList<String>();
emlore.add("emeralds are cool.");
EntityPlayer stupid=?;
boolean par4 = true;
Items.EMERALD.addInformation(new ItemStack(Items.EMERALD), stupid, emlore, par4);
in preinit but as you can tell I have no idea what to put in EntityPlayer.
You shouldn't ever call the method like that yourself (unless you have a specific good reason to)... it's called by vanilla code when you hover over the item to produce the tooltip. That's why you should override the method in your item's class to return the desired text you want to display. Just like most of the examples in this thread.
You shouldn't ever call the method like that yourself (unless you have a specific good reason to)... it's called by vanilla code when you hover over the item to produce the tooltip. That's why you should override the method in your item's class to return the desired text you want to display. Just like most of the examples in this thread.
That is fine for a custom item. What do I do for a vanilla item though?
if you override addInformation then you can add lore by doing par3List.add your "par3list" may be called something else but it is the 3 variable in the funciton and is type "List"
Here's the Minecraft wiki page on text formatting codes.
If you want each item to have its own specific lore, you're gonna have to look into editing NBT tags.
I tried doing that, however it does not display the information under the name of the item.
Look in the ItemStack code where it gets the tooltip display, you'll see:
So once you create your new ItemStack with your name, just get the stack tag compound, get the tag list "Lore" and add whatever you want to it.
my Version
This is easy-
}
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par2List, boolean par4)
{
par2List.add("\u00a76" + "A legendary sword made from the ashes of the nether.");
par2List.add("\u00a75" + "Found In Sand temples");
}
}
Inactive account
i know right if you want you can add a class e.g. (ItemLore) And When You Register the item you can set it to do this |||| ItemLore("A Chicken Nugget") |||
easily with this code
package com.foodplusp.main.items;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemLore extends Item{
public String LORE;
public ItemLore(String lore) {
LORE = lore;
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(LORE);
}
}
Just in case some one (like me) finds this thread a few years later; a modified version of Dylan's code;
you don't need a new class, simply put this at the bottom of the default BaseBlock class. (ShadowFacts Tutorials helped me set up most of the mod)
Out of the water and into...the thaumic crucible
So I don't understand what you mean by this and how to ensure it gets called. I'm trying to add Lore to something, say Emeralds.
I've been trying something like
in preinit but as you can tell I have no idea what to put in EntityPlayer.
You shouldn't ever call the method like that yourself (unless you have a specific good reason to)... it's called by vanilla code when you hover over the item to produce the tooltip. That's why you should override the method in your item's class to return the desired text you want to display. Just like most of the examples in this thread.
That is fine for a custom item. What do I do for a vanilla item though?
You need to subscribe to the ItemTooltipEvent
That sounds like the most boring magazine ever. I'll try it.
if you override addInformation then you can add lore by doing par3List.add your "par3list" may be called something else but it is the 3 variable in the funciton and is type "List"
Out of the water and into...the thaumic crucible