Jump to content

Recommended Posts

Posted

Hello, I'm trying to make it so my amulet item has a description under it, which is similar to the music disc where it says the disc number and name. I have the following code and there is a plus sign that adds that string to the actual name and the name becomes "Turns time to dayAmulet of Day" instead of "Amulet of Day" (with the string under it).

 

This code is from the minecraft "Item" File and I dont know how to change it to not make it add itself to the name (unless its supposed to?)

 

Code Block:

 

 

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {}

 

    public String getItemDisplayName(ItemStack par1ItemStack)

    {

        return ("Turns time to day" + StringTranslate.getInstance().translateNamedKey(this.getLocalizedName(par1ItemStack))).trim();

    }

 

 

 

Full Item Code:

 

 

package mods.magicalAmulets.common;

 

import java.awt.List;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.EnumRarity;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.StringTranslate;

import net.minecraft.world.World;

 

public class ItemAmuletDay extends Item{

 

public ItemAmuletDay(int par1) {

super(par1);

this.setMaxStackSize(1);

this.setCreativeTab(CreativeTabs.tabTools);

}

 

public EnumRarity getRarity(ItemStack is){

return EnumRarity.epic;

}

 

public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entity){

float var4 = 1.0F;

int i = (int)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)var4);

int j = (int)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)var4 + 1.62D - (double)entity.yOffset);

int k = (int)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)var4);

 

world.setWorldTime(0);

return itemstack;

}

 

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {}

 

    public String getItemDisplayName(ItemStack par1ItemStack)

    {

        return ("Turns time to day" + StringTranslate.getInstance().translateNamedKey(this.getLocalizedName(par1ItemStack))).trim();

    }

}

 

 

 

 

Thanks!

Posted

here is an example of how to use it Im sure you can figure out from there :)

 

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

par3List.add("Hello World!");

}

 

Don't you need to @Override that? I may be wrong though...

Posted

This works for me:

 

    @SideOnly(Side.CLIENT)
    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    {
        par3List.add("Line I");
        par3List.add("Line II");
    }

Thanks...!

Posted

Don't you need to @Override that? I may be wrong though...

 

@Override is only an annotation.  A fancy comment that makes the IDE do extra error checking.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.