Skip to content

Commit

Permalink
Add ItemStackEditor#andMetaConsumer(Class, Consumer) (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 authored Nov 9, 2024
1 parent 6352dc6 commit cb22e71
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 cb22e71

Please sign in to comment.