use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.
the class BlueprintItem method convertIItemListToFilter.
private static ItemStack convertIItemListToFilter(Value itemList) {
Collection<ItemStack> stacks = itemList.getItems();
if (itemList instanceof ItemValue) {
for (ItemStack itemStack : stacks) return itemStack;
}
if (itemList instanceof TagValue) {
ResourceLocation resourcelocation = new ResourceLocation(GsonHelper.getAsString(itemList.serialize(), "tag"));
ItemStack filterItem = AllItems.ATTRIBUTE_FILTER.asStack();
filterItem.getOrCreateTag().putInt("WhitelistMode", WhitelistMode.WHITELIST_DISJ.ordinal());
ListTag attributes = new ListTag();
ItemAttribute at = new ItemAttribute.InTag(resourcelocation);
CompoundTag compoundNBT = new CompoundTag();
at.serializeNBT(compoundNBT);
compoundNBT.putBoolean("Inverted", false);
attributes.add(compoundNBT);
filterItem.getOrCreateTag().put("MatchedAttributes", attributes);
return filterItem;
}
if (itemList instanceof MultiItemValue) {
ItemStack result = AllItems.FILTER.asStack();
ItemStackHandler filterItems = FilterItem.getFilterItems(result);
int i = 0;
for (ItemStack itemStack : stacks) {
if (i >= 18)
break;
filterItems.setStackInSlot(i++, itemStack);
}
CompoundTag tag = result.getOrCreateTag();
tag.put("Items", filterItems.serializeNBT());
tag.putBoolean("RespectNBT", true);
return result;
}
return ItemStack.EMPTY;
}
Aggregations