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

1.18 no getTag() #40

Open
fafa-junhe opened this issue Jun 23, 2022 · 1 comment
Open

1.18 no getTag() #40

fafa-junhe opened this issue Jun 23, 2022 · 1 comment

Comments

@fafa-junhe
Copy link

getTag() only exists on 1.17 version.

    public static Optional<Integer> getInt(ItemStack item, String key) {
        Optional<net.minecraft.world.item.ItemStack> item1;
        try {
            item1 = getItem(item);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            return Optional.empty();
        }
        if (item1.isEmpty()) return Optional.empty();
        NBTTagCompound tag = item1.get().getTag(); // exception
        if (tag == null) return Optional.empty();
        return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getInt(key));
    }

from https://github.com/NyaaCat/NyaaCore/blob/1.18/src/main/java/cat/nyaa/nyaacore/utils/ItemTagUtils.java

@Takaranoao
Copy link
Contributor

I don't have this problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants