Search in sources :

Example 1 with ItemAttribute

use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.

the class BlueprintOverlayRenderer method getItemsMatchingFilter.

private static ItemStack[] getItemsMatchingFilter(ItemStack filter) {
    return cachedRenderedFilters.computeIfAbsent(filter, itemStack -> {
        CompoundTag tag = itemStack.getOrCreateTag();
        if (AllItems.FILTER.isIn(itemStack) && !tag.getBoolean("Blacklist")) {
            ItemStackHandler filterItems = FilterItem.getFilterItems(itemStack);
            List<ItemStack> list = new ArrayList<>();
            for (int slot = 0; slot < filterItems.getSlots(); slot++) {
                ItemStack stackInSlot = filterItems.getStackInSlot(slot);
                if (!stackInSlot.isEmpty())
                    list.add(stackInSlot);
            }
            return list.toArray(new ItemStack[list.size()]);
        }
        if (AllItems.ATTRIBUTE_FILTER.isIn(itemStack)) {
            WhitelistMode whitelistMode = WhitelistMode.values()[tag.getInt("WhitelistMode")];
            ListTag attributes = tag.getList("MatchedAttributes", net.minecraft.nbt.Tag.TAG_COMPOUND);
            if (whitelistMode == WhitelistMode.WHITELIST_DISJ && attributes.size() == 1) {
                ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0));
                if (fromNBT instanceof ItemAttribute.InTag) {
                    ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT;
                    Tag<Item> itag = ItemTags.getAllTags().getTag(inTag.tagName);
                    if (itag != null)
                        return Ingredient.of(itag).getItems();
                }
            }
        }
        return new ItemStack[0];
    });
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) ArrayList(java.util.ArrayList) ListTag(net.minecraft.nbt.ListTag) FilterItem(com.simibubi.create.content.logistics.item.filter.FilterItem) Item(net.minecraft.world.item.Item) WhitelistMode(com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode) ItemStack(net.minecraft.world.item.ItemStack) ItemAttribute(com.simibubi.create.content.logistics.item.filter.ItemAttribute) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 2 with ItemAttribute

use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.

the class AstralSorceryAttunementAttribute method listAttributesOf.

@Override
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
    CompoundTag nbt = extractAstralNBT(itemStack);
    String constellation = nbt.contains("constellation") ? nbt.getString("constellation") : nbt.getString("constellationName");
    // Special handling for shifting stars
    ResourceLocation itemResource = itemStack.getItem().getRegistryName();
    if (itemResource != null && itemResource.toString().contains("shifting_star_")) {
        constellation = itemResource.toString().replace("shifting_star_", "");
    }
    List<ItemAttribute> atts = new ArrayList<>();
    if (constellation.length() > 0) {
        atts.add(new AstralSorceryAttunementAttribute(constellation));
    }
    return atts;
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) ArrayList(java.util.ArrayList) ItemAttribute(com.simibubi.create.content.logistics.item.filter.ItemAttribute) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 3 with ItemAttribute

use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.

the class AstralSorceryPerkGemAttribute method listAttributesOf.

@Override
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
    ListTag traits = extractTraitList(itemStack);
    List<ItemAttribute> atts = new ArrayList<>();
    for (int i = 0; i < traits.size(); i++) {
        atts.add(new AstralSorceryPerkGemAttribute(traits.getCompound(i).getString("type")));
    }
    return atts;
}
Also used : ArrayList(java.util.ArrayList) ItemAttribute(com.simibubi.create.content.logistics.item.filter.ItemAttribute) ListTag(net.minecraft.nbt.ListTag)

Example 4 with ItemAttribute

use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.

the class AstralSorceryAmuletAttribute method listAttributesOf.

@Override
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
    ListTag traits = extractTraitList(itemStack);
    List<ItemAttribute> atts = new ArrayList<>();
    for (int i = 0; i < traits.size(); i++) {
        atts.add(new AstralSorceryAmuletAttribute(traits.getCompound(i).getString("ench"), traits.getCompound(i).getInt("type")));
    }
    return atts;
}
Also used : ArrayList(java.util.ArrayList) ItemAttribute(com.simibubi.create.content.logistics.item.filter.ItemAttribute) ListTag(net.minecraft.nbt.ListTag)

Example 5 with ItemAttribute

use of com.simibubi.create.content.logistics.item.filter.ItemAttribute in project Create by Creators-of-Create.

the class AstralSorceryCrystalAttribute method listAttributesOf.

@Override
public List<ItemAttribute> listAttributesOf(ItemStack itemStack) {
    ListTag traits = extractTraitList(itemStack);
    List<ItemAttribute> atts = new ArrayList<>();
    for (int i = 0; i < traits.size(); i++) {
        atts.add(new AstralSorceryCrystalAttribute(traits.getCompound(i).getString("property")));
    }
    return atts;
}
Also used : ArrayList(java.util.ArrayList) ItemAttribute(com.simibubi.create.content.logistics.item.filter.ItemAttribute) ListTag(net.minecraft.nbt.ListTag)

Aggregations

ItemAttribute (com.simibubi.create.content.logistics.item.filter.ItemAttribute)6 ArrayList (java.util.ArrayList)5 ListTag (net.minecraft.nbt.ListTag)5 CompoundTag (net.minecraft.nbt.CompoundTag)3 ResourceLocation (net.minecraft.resources.ResourceLocation)2 ItemStack (net.minecraft.world.item.ItemStack)2 ItemStackHandler (net.minecraftforge.items.ItemStackHandler)2 WhitelistMode (com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode)1 FilterItem (com.simibubi.create.content.logistics.item.filter.FilterItem)1 Item (net.minecraft.world.item.Item)1 ItemValue (net.minecraft.world.item.crafting.Ingredient.ItemValue)1 TagValue (net.minecraft.world.item.crafting.Ingredient.TagValue)1 MultiItemValue (net.minecraftforge.common.crafting.MultiItemValue)1