NBT-API

NBT-API

98.9k Downloads

function to parse item in chat with lore

Twi5TeD opened this issue ยท 1 comments

commented

atm im using

 Player player = (Player) sender;
        ItemStack i = player.getInventory().getItemInMainHand();
        CraftItemStack stack = CraftItemStack.asCraftCopy(i);
        net.minecraft.server.v1_12_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);
        NBTTagCompound tagCompound = new NBTTagCompound();
        nmsStack.save(tagCompound);
            TextComponent textComponent = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&f" + sender.getName() + " &7is showcasing &b[" + fullName(i, player.getInventory().getContents()) + "&b]"));
            textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(tagCompound.toString()).create()));
            p.spigot().sendMessage(textComponent);

to show the item in chat with lore for 1.12 but i wont other client version to be able to see them aswell

commented

This is a stale question, in short: That's a ViaVersion problem that doesn't seem to be get fixed and I can't really do anything about it.
The code above can be simplified by removing the NMS stuff and replacing it to get the Json by: NBTItem.convertItemtoNBT(item).toString():