Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/84e5698e47dfa2216bf9 to your computer and use it in GitHub Desktop.
Save anonymous/84e5698e47dfa2216bf9 to your computer and use it in GitHub Desktop.
/**
* Created by toblexson on 11/01/2016.
*/
public class ItemDiscSleeve extends SCBaseItem
{
public ItemDiscSleeve()
{
super(SCNames.Items.DISC_SLEEVE);
setMaxStackSize(1);
}
@Override
public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
stack.setTagCompound(new NBTTagCompound());
}
@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if(playerIn.isSneaking())
{
playerIn.openGui(SoundControl.instance, SCGuiHandler.DISC_SLEEVE_GUI, worldIn, (int)playerIn.posX, (int)playerIn.posY, (int)playerIn.posZ);
}
return itemStackIn;
}
@Override
public int getMaxItemUseDuration(ItemStack stack)
{
return 1;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
if(stack.hasTagCompound())
{
NBTTagCompound compound = stack.getTagCompound();
NBTTagList list = compound.getTagList("Items", 10);
for(int i = 0; i < list.tagCount(); i++)
{
NBTTagCompound tag = list.getCompoundTagAt(i);
String itemName = ItemStack.loadItemStackFromNBT(tag).getTooltip(playerIn, advanced).toString();
itemName = itemName.replace("Music Disc", "");
itemName = itemName.replace("[", "");
itemName = itemName.replace(",", "");
itemName = itemName.replace("]", "");
tooltip.add(itemName);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment