I'm trying to create a command that Changes the nbt data of the currently held item.
Ive gotten to the point where everything works except for this line.
EntityPlayer player= sender.getDisplayName();
@Override
public void processCommand(ICommandSender sender, String[] args)
{
String output = String.join(" ", args);
if(args.length == 0)
{
throw new CommandException("no name defined");
}
else
{
EntityPlayer player= sender.getDisplayName();
ItemStack stack = player.getHeldItem();
addInformation(stack, player, output);
}
}
public void addInformation(ItemStack istack, EntityPlayer player, String itemname)
{
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 tagname = tag.getCompoundTag("display");
NBTTagList name = new NBTTagList();
name.appendTag(new NBTTagString("§b"+itemname));
tagname.setTag("Name", name);
}