Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -190,26 +194,27 @@ default INbtIngredient withNbtExact(NBTTagCompound nbt) {
}

default INbtIngredient withNbtFilter(Predicate<NBTTagCompound> 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 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 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) {
Expand Down