Posted August 7, 201312 yr hello! The title explains everything. what i want to have is a random generated number pre item(which i do), but now i want to display that item. Do i still use the ItemStack.StackTagCompoud or what? Please help! What i have so far: package com.gmod622.SickMod.item; import java.util.List; import com.gmod622.SickMod.tile.TileEntityLicense; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class LicenseItemClass extends Item { public LicenseItemClass(int par1) { super(par1); this.setCreativeTab(CreativeTabs.tabMaterials); } public static int theRandom; public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { //here you can use the information about the itemstack nbt //ex: if(par1ItemStack.stackTagCompound == null){ //here we know the nbt is null par1ItemStack.stackTagCompound = new NBTTagCompound(); }else { theRandom = par1ItemStack.stackTagCompound.getInteger("myRandomNumber"); if(theRandom == 0){ //here we DONT have anythin on the stack compound par1ItemStack.stackTagCompound.setInteger("myRandomNumber", (int)(Math.random()*100000));//generate a number between 0-100 and place it on the nbt }else{ System.out.println("the number of this item is: "+theRandom); } } return par1ItemStack; } } Not new to java >> New to modding.
August 7, 201312 yr @SideOnly(Side.CLIENT) /** * allows items to add custom lines of information to the mouseover description */ public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {} In Item class. Not sure if that is what you want.
August 7, 201312 yr Author I have a randomly generated number by using ItemStackNBT. if i would do that all of the ids will be the same on the cards Not new to java >> New to modding.
August 7, 201312 yr The first argument from that method is the ItemStack. Get the id from its NBT, then add this id to the list. It will be displayed different for each.
August 8, 201312 yr Author Well, can you be just a little bit more discriptive Not new to java >> New to modding.
August 8, 201312 yr Something like: // package here // imports here public class ItemRandomIDItem extends Item { // typical Item stuff here public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4 { NBTTagCompound stackCompound = ItemStack.getItemStackNBTTagCompount(); // whatever it is to get it int idToDisplay = stackCompound.getInteger("theRandomID"); par3List.add("ID: " + idToDisplay); } // other Item stuff } I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
August 8, 201312 yr Author this line: NBTTagCompound stackCompound = ItemStack.getItemStackNBTTagCompound(); // whatever it is to get it getItemStackNBTTagCompound isnt a method( I really newbie with ItemStacks and NBTs, sorry) Not new to java >> New to modding.
August 8, 201312 yr I know it isn't. I just wrote that with the comment saying, WHATEVER IT IS. meaning I have no idea what the method is, but I know it's there... I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
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.