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

ItemUtils#changeItemMeta, #setItem #7217

Open
wants to merge 5 commits into
base: dev/feature
Choose a base branch
from

Conversation

TheAbsolutionism
Copy link
Contributor

@TheAbsolutionism TheAbsolutionism commented Nov 15, 2024

Description

This PR is to help with shorthand ItemStack changes.
Example: (Before)

for (Object object : getExpr().getArray(event)) {
    ItemStack item = ItemUtils.asItemStack(object);
    if (item == null)
        continue;
    ItemMeta meta = item.getItemMeta();
    consumer.accept(meta);
    item.setItemMeta(meta);
    if (object instanceof Slot slot) {
        slot.setItem(item);
    } else if (object instaceof ItemType itemType) {
        itemType.setItemMeta(meta);
    } else if (object instanceof ItemStack itemStack) {
        itemStack.setItemMeta(meta);
    }
}

(After)

for (Object object : getExpr().getArray(event)) {
    ItemStack item = ItemUtils.asItemStack(object);
    if (item == null)
        continue;
    ItemUtils.setItem(object, ItemUtils.changeItemMeta(item, consumer));
}

Obviously this will more than likely be up for debate but here's hoping.


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@sovdeeth sovdeeth added the feature Pull request adding a new feature. label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants