Skip to content

Commit

Permalink
Add andMetaConsumer(Class, Consumer)
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Nov 9, 2024
1 parent 6352dc6 commit 285312d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ public ItemStackEditor andMetaConsumer(Consumer<ItemMeta> consumer) {
return withMetaConsumer(this.metaTransform.andThen(consumer));
}

public <T extends ItemMeta> ItemStackEditor andMetaConsumer(Class<T> clazz, Consumer<T> consumer) {
return andMetaConsumer(meta -> {
if (clazz.isInstance(meta)) {
consumer.accept(clazz.cast(meta));
}
});
}

public ItemStackEditor withMetaConsumer(@Nullable Consumer<ItemMeta> consumer) {
return new ItemStackEditor(this.itemStack, consumer, this.stackTransform);
}
Expand Down

0 comments on commit 285312d

Please sign in to comment.