Jump to content

AddInformation not working


Casual Dutchman

Recommended Posts

I created a custom Irecipe that adds a tier upon a succesfull recipe.

 

But then comes the problem.

Now I created a the AddInformation(things) methode to display more information.

 

It just does not display.

 

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if(par1ItemStack.hasTagCompound()){

		NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack");

		if(nbttagcompound != null){

			if(nbttagcompound.hasKey("tier")){

				int tier = nbttagcompound.getInteger("tier");

				String sayTier = "Tier " + tier;
				par3List.add(sayTier);
			}
		}
	}

	String info = "info";
	par3List.add(info);
}

 

the wierd part is, "info" is not even displayed!

Coding, Testing, Smiling, Publishing!

Link to comment
Share on other sites

I'm sorry? Minecraft will get the methode as an overwritten methode.

 

In the ItemStack class the methode is called int the getToolTip mothode.

It will then get the addinformation methode from the item in the itemstack.

if the custom item does not have this methode, it will use the empty methode in the Item class.

 

btw, it did not work? I have no clue why not?

 

look at the first and the second methode!

the first one will display the information and de second not!

 

//nothing fancy here, no override, no sideonly, nothing
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
  String info = EnumChatFormatting.DARK_GRAY + "A very effective melee weapon";
  String info2 = EnumChatFormatting.DARK_GRAY + "Shift-Right-Click a door to instantly smash it";

    
  par3List.add(info);
  par3List.add(info2);
    	
}
//Works great

 

@Override //<= just this!
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if(par1ItemStack.hasTagCompound()){

		NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack");

		if(nbttagcompound != null){

			if(nbttagcompound.hasKey("tier")){

				int tier = nbttagcompound.getInteger("tier");

				String sayTier = "Tier " + tier;
				par3List.add(sayTier);
			}
		}
	}

	String info = "info";
	par3List.add(info);
}
//does not display!

Coding, Testing, Smiling, Publishing!

Link to comment
Share on other sites

I did not say that, I was just saying that you don't need it, it is usefull to see if the methode corresponds to the methode called by the extended class.

 

With or without the @Override annotation, it does not work and I hace copied the methode over and over again from various other classes.

 

Here is the Item class:

nothing strange, no errors, registered just like other items. I just have no clue

package mefa.Items;

import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class ItemBackpack extends Item{

public ItemBackpack()
{
	super();
	this.setMaxStackSize(1);
}

@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if(par1ItemStack.hasTagCompound()){

		NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack");

		if(nbttagcompound != null){

			if(nbttagcompound.hasKey("tier")){

				int tier = nbttagcompound.getInteger("tier");

				String sayTier = "Tier " + tier;
				par3List.add(sayTier);
			}
		}
	}

	String info = "info";
	par3List.add(info);
}
}

Coding, Testing, Smiling, Publishing!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.