1.15.2 How i can set the ItemMeta display name with ChatComponent ?

Discussion in 'Spigot Plugin Development' started by AndRo_Marian, Jan 9, 2020.

  1. I'm new in this and i want to know if is possible to set the Item name to be translated by the Client, like how tellraw works:

    Code (Text):
    /minecraft:tellraw @a [{"translate":"entity.minecraft.zombie"},{"text":" "},{"translate":"entity.minecraft.villager.farmer"}]
    Thanks.

    Edit: How i use TextComponent to NBTBase to set the NBT tag
    Code (Text):
    display: [{"translate":"entity.minecraft.zombie"},{"text":" "},{"translate":"entity.minecraft.villager.farmer"}]
    Something like:
    Code (Text):
                    var item2 = CraftItemStack.asNMSCopy(item);
                    var nbt = new NBTTagCompound();

                    var text = new TextComponent();

                    text.addExtra(new TranslatableComponent("entity.minecraft.zombie"));
                    text.addExtra(" ");
                    text.addExtra(new TranslatableComponent("entity.minecraft.villager.farmer"));

                    nbt.set("display", text);
                    item2.save(nbt);
    But is not that simple, or if is possible somehow.
     
    #1 AndRo_Marian, Jan 9, 2020
    Last edited: Jan 9, 2020
  2. Please search the forums before posting, this one is the top post on page 2.
     
  3. LocalizedName is does nothing. still i see the default DisplayName of the item. And is for Server side, not client side. So the name is empty or will be in English.
    Already searched 2 days, found nothing.
    Not the same thing.
     
    #3 AndRo_Marian, Jan 9, 2020
    Last edited: Jan 9, 2020
  4. Correct. It's not server side, but that is not why the name is in English like you said its client-side.
    From getLocalizedName():