From 285312d17d128cd9cfd7b6ac9099e230aa595d50 Mon Sep 17 00:00:00 2001 From: Andrew Wong <42793301+md5sha256@users.noreply.github.com> Date: Sat, 9 Nov 2024 18:22:01 +1100 Subject: [PATCH] Add andMetaConsumer(Class, Consumer) --- .../io/github/bakedlibs/dough/items/ItemStackEditor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dough-items/src/main/java/io/github/bakedlibs/dough/items/ItemStackEditor.java b/dough-items/src/main/java/io/github/bakedlibs/dough/items/ItemStackEditor.java index d86268ef..32a0bfdb 100644 --- a/dough-items/src/main/java/io/github/bakedlibs/dough/items/ItemStackEditor.java +++ b/dough-items/src/main/java/io/github/bakedlibs/dough/items/ItemStackEditor.java @@ -92,6 +92,14 @@ public ItemStackEditor andMetaConsumer(Consumer consumer) { return withMetaConsumer(this.metaTransform.andThen(consumer)); } + public ItemStackEditor andMetaConsumer(Class clazz, Consumer consumer) { + return andMetaConsumer(meta -> { + if (clazz.isInstance(meta)) { + consumer.accept(clazz.cast(meta)); + } + }); + } + public ItemStackEditor withMetaConsumer(@Nullable Consumer consumer) { return new ItemStackEditor(this.itemStack, consumer, this.stackTransform); }