Skip to content

Commit cb22e71

Browse files
authored
Add ItemStackEditor#andMetaConsumer(Class, Consumer) (#277)
1 parent 6352dc6 commit cb22e71

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

dough-items/src/main/java/io/github/bakedlibs/dough/items/ItemStackEditor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ public ItemStackEditor andMetaConsumer(Consumer<ItemMeta> consumer) {
9292
return withMetaConsumer(this.metaTransform.andThen(consumer));
9393
}
9494

95+
public <T extends ItemMeta> ItemStackEditor andMetaConsumer(Class<T> clazz, Consumer<T> consumer) {
96+
return andMetaConsumer(meta -> {
97+
if (clazz.isInstance(meta)) {
98+
consumer.accept(clazz.cast(meta));
99+
}
100+
});
101+
}
102+
95103
public ItemStackEditor withMetaConsumer(@Nullable Consumer<ItemMeta> consumer) {
96104
return new ItemStackEditor(this.itemStack, consumer, this.stackTransform);
97105
}

0 commit comments

Comments
 (0)