From 96c1691c8546f27430f8278f785a63a46b0b7cfc Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Sun, 15 Feb 2026 04:56:38 -0800 Subject: [PATCH 1/3] fix matcher check --- .../compat/vanilla/ItemStackMixinExpansion.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java index ce7e5326a..d8434624e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java @@ -66,12 +66,16 @@ default ItemStackMixinExpansion exactCopy() { @Override default boolean test(ItemStack stack) { - if (!OreDictionary.itemMatches(grs$getItemStack(), stack, false) || (grs$getMatcher() != null && !grs$getMatcher().test(stack))) { + var matcher = grs$getMatcher(); + if (matcher != null) { + if (!matcher.test(stack)) return false; + } else if (!OreDictionary.itemMatches(grs$getItemStack(), stack, false)) { return false; } - if (grs$getNbtMatcher() != null) { + var nbtMatcher = grs$getNbtMatcher(); + if (nbtMatcher != null) { NBTTagCompound nbt = stack.getTagCompound(); - return nbt != null && grs$getNbtMatcher().test(nbt); + return nbt != null && nbtMatcher.test(nbt); } return true; } From 7178de84bf5ab87aebbf74e7634d396a19e0a04c Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Sun, 15 Feb 2026 05:02:51 -0800 Subject: [PATCH 2/3] make nbt matchers check item + meta --- .../groovyscript/compat/vanilla/ItemStackMixinExpansion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java index d8434624e..85e9c7fb6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java @@ -202,7 +202,7 @@ default INbtIngredient whenNoNbt() { setNbt(null); grs$setMatcher(self -> { NBTTagCompound nbt = self.getTagCompound(); - return nbt == null || nbt.isEmpty(); + return OreDictionary.itemMatches(grs$getItemStack(), self, false) && (nbt == null || nbt.isEmpty()); }); return this; } @@ -211,7 +211,7 @@ default INbtIngredient whenAnyNbt() { setNbt(new NBTTagCompound()); grs$setMatcher(self -> { NBTTagCompound nbt = self.getTagCompound(); - return nbt != null && !nbt.isEmpty(); + return OreDictionary.itemMatches(grs$getItemStack(), self, false) && nbt != null && !nbt.isEmpty(); }); return this; } From 5b86827b3b3f504d3980493be2cb02ee4299f680 Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Sun, 15 Feb 2026 05:09:04 -0800 Subject: [PATCH 3/3] make copies for other when/with methods --- .../vanilla/ItemStackMixinExpansion.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java index 85e9c7fb6..924a6c604 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java @@ -194,26 +194,27 @@ default INbtIngredient withNbtExact(NBTTagCompound nbt) { } default INbtIngredient withNbtFilter(Predicate nbtFilter) { - this.grs$setNbtMatcher(nbtFilter == null ? nbt -> true : nbtFilter); - return this; + ItemStackMixinExpansion itemStackMixin = exactCopy(); + itemStackMixin.grs$setNbtMatcher(nbtFilter == null ? nbt -> true : nbtFilter); + return itemStackMixin; } default INbtIngredient whenNoNbt() { - setNbt(null); - grs$setMatcher(self -> { - NBTTagCompound nbt = self.getTagCompound(); - return OreDictionary.itemMatches(grs$getItemStack(), self, false) && (nbt == null || nbt.isEmpty()); - }); - return this; + var itemStackMixin = of(when(stack -> { + NBTTagCompound nbt = stack.getTagCompound(); + return OreDictionary.itemMatches(grs$getItemStack(), stack, false) && (nbt == null || nbt.isEmpty()); + })); + itemStackMixin.setNbt(null); + return itemStackMixin; } default INbtIngredient whenAnyNbt() { - setNbt(new NBTTagCompound()); - grs$setMatcher(self -> { - NBTTagCompound nbt = self.getTagCompound(); - return OreDictionary.itemMatches(grs$getItemStack(), self, false) && nbt != null && !nbt.isEmpty(); - }); - return this; + var itemStackMixin = of(when(stack -> { + NBTTagCompound nbt = stack.getTagCompound(); + return OreDictionary.itemMatches(grs$getItemStack(), stack, false) && nbt != null && !nbt.isEmpty(); + })); + itemStackMixin.setNbt(new NBTTagCompound()); + return itemStackMixin; } default ItemStack withMeta(int meta) {