Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add item name translation #559

Merged
merged 6 commits into from
Jun 2, 2020
Merged

Conversation

rtm516
Copy link
Member

@rtm516 rtm516 commented May 14, 2020

Fixes: #555
Fixes: #508

@rtm516 rtm516 added the PR: Bugfix When a PR contains a bugfix label May 14, 2020
@lukeeey
Copy link
Member

lukeeey commented May 14, 2020

I think the item translator needs some rewriting... I did it like this

 @Override
    public CompoundTag translateToBedrock(com.github.steveice10.opennbt.tag.builtin.CompoundTag javaTag) {
        CompoundTagBuilder root = CompoundTagBuilder.builder();

        if(!javaTag.contains("display")) {
            CompoundTagBuilder display = CompoundTagBuilder.builder();

            if (javaTag.contains("name")) {
                display.stringTag("Name", Message.fromString((String) javaTag.get("name").getValue()).getFullText());
                javaTag.remove("name");
            }
            if (javaTag.contains("lore")) {
                com.nukkitx.nbt.tag.ListTag list = (com.nukkitx.nbt.tag.ListTag) ItemTranslatorRegistry.translateRawNBT((Tag) javaTag.get("lore"));
                // noinspection unchecked
                display.listTag("Lore", com.nukkitx.nbt.tag.StringTag.class, list.getValue());
                javaTag.remove("lore");
            }
            root.tag(display.build("display"));
        }
        return root.buildRootTag();
    }

@Camotoy
Copy link
Member

Camotoy commented May 14, 2020

Oh, absolutely, Geyser's item translating needs rewriting. I'm not quite sure how it's done right now.

@rtm516 rtm516 marked this pull request as draft May 14, 2020 20:46
@rtm516 rtm516 added the Work in Progress The issue is currently being worked on. label May 23, 2020
@rtm516 rtm516 marked this pull request as ready for review June 1, 2020 21:53
@rtm516 rtm516 removed the Work in Progress The issue is currently being worked on. label Jun 1, 2020
@Camotoy Camotoy changed the title Added item name translation Add item name translation Jun 1, 2020
@Camotoy Camotoy merged commit a91eaa7 into GeyserMC:master Jun 2, 2020
@rtm516 rtm516 deleted the translate-item-names branch June 3, 2020 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bugfix When a PR contains a bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ominous banner does not have translation Item Names are JSON strings sometimes on Bedrock
3 participants