I don't really understand how to do this correctly. DisplayName seems to be changing, but the name of item in result slot remains the same. Here is my code. Sorry if it`s dumb, this is the first time I've encountered this
And here is what i get in console
Java:
AnvilInventory anvilInventory = event.getInventory();
if (anvilInventory.getSecondItem() == null) {
if (anvilInventory.getResult() != null) {
ItemStack resultItem = anvilInventory.getResult();
ItemMeta resultItemMeta = resultItem.getItemMeta();
ProjectAnvils.getPlugin(ProjectAnvils.class).getLogger().info("Old display name " + resultItemMeta.displayName());
resultItemMeta.displayName(Component.text("dog"));
resultItem.setItemMeta(resultItemMeta);
ProjectAnvils.getPlugin(ProjectAnvils.class).getLogger().info("New display name " + resultItemMeta.displayName());
anvilInventory.setResult(resultItem);
ProjectAnvils.getPlugin(ProjectAnvils.class).getLogger().info(String.valueOf(resultItem));
}
}
And here is what i get in console
[02:58:34 INFO]: [ProjectAnvils] Old display name TextComponentImpl{content="Трезубецa", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
[02:58:34 INFO]: [ProjectAnvils] New display name TextComponentImpl{content="dog", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
[02:58:34 INFO]: [ProjectAnvils] ItemStack{TRIDENT x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name="dog"}}
[02:58:34 INFO]: [ProjectAnvils] New display name TextComponentImpl{content="dog", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
[02:58:34 INFO]: [ProjectAnvils] ItemStack{TRIDENT x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name="dog"}}