This article describes a new feature added to ItemBags version 3.1.0. Normally, to create a modded bag, you must explicitly specify each item that the bag can store. ItemFilters allow you to define the bag's items in a more convenient way by using filters to match the items against. Any items that pass the filters will be storeable in the modded bag.

You must install ItemBags version 3.1.0 or later to use these features

Basic Usage

Spoiler:  
Show

To use ItemFilters, add the ItemFilters json property to the modded bag's .json file. This property is an array of strings, where each entry describes one or more filters:

{
    ...
    "ItemFilters": [
        "CategoryId:-4"
    ]
    ...
}

This would match all items belonging to Category=-4 (fish category). There are several filter types you can use, such as "FromMod" to match items belonging to a particular ModId.

Each filter is defined in the format: "{FilterType}:{FilterValue}". Some FilterTypes do not require a value, such as the "IsPendingDonation" filter, which matches items that haven't been donated to the museum yet:

{
    ...
    "ItemFilters": [
        "IsPendingDonation"
    ]
    ...
}



OR-ing and AND-ing filters together
Spoiler:  
Show
You can specify multiple filters in the same entry, separated by a vertical bar character (|). Each filter will be logically OR-ed together, so the resulting combination filter will match any items that pass at least one of the filters in the entry.

{
    ...
    "ItemFilters": [
        "FromMod:Rafseazz.RSVCP|FromMod:FlashShifter.StardewValleyExpandedCP"
    ]
    ...
}

This would match all items that were added by either Rideside Village (Rafseazz.RSVCP) OR Stardew Valley Expanded (FlashShifter.StardewValleyExpandedCP).

If you specify multiple entries in the array, they will be logically AND-ed together, so the resulting combination filter will match items that pass ALL of the filters that were AND-ed together.

{
    ...
    "ItemFilters": [
"FromMod:Rafseazz.RSVCP",
"HasBuffs|CategoryId:-4"
    ]
    ...
}

This would match items from Rideside Village that either have buffs OR are fish items. (So the logic is essentially: "(Is from RSV) AND (Has Buffs OR Category=-4)"). Notice that we mix and matched, by using a filter composed via logical OR-ing, and a filter composed via logical AND-ing.


Negation Operator
Spoiler:  
Show
If you prefix a filter type with an exclamation point (!), the filter will be negated. I.E. it will match items that are the opposite of what it would normally match.

{
    ...
    "ItemFilters": [
"!FromMod:Rafseazz.RSVCP",
"CategoryId:-4"
    ]
    ...
}

This would match all fish items (Category=-4) that are NOT from RSV mod.


Sorting
Spoiler:  
Show

By default, item's in the bag's menu will appear in the order they were found within the game's item database. If you had a bag that was matching any fruits or vegetable ("CategoryId:-79|CategoryId:-75"), which would be shown first in the topleft of the bag menu? The fruits? Or the vegetables? I have no idea how the game's item database is ordered so you'd just have to test it and see the result.

Luckily if you want more control over the ordering, you can add the ItemFiltersSorting property to the modded bag's .json file.
The value should be a comma-separated list of the properties to sort by, where the property can be any of the following:
CategoryId
Price
ObjectType
Edibility (an integer value that determines the item's health/energy restoration)
InternalName (the un-localized English item name)
DisplayName (The localized item name)
LocalId (The unualified Id)
QualifiedId (The fully-qualified Id which includes the item type such as "(O)" or "(BC)")

{
...
"ItemFiltersSorting": "DisplayName"
...
}


"DisplayName" would sort the results by their displayname. "CategoryId,DisplayName" would first sort the items by their category, then by their displayname.

You can optionally suffix each value with a hyphen followed by either "Ascending" or "Descending" to control the sorting direction:
"CategoryId-Descending,DisplayName-Ascending"
If no direction is specified, it will use Ascending order.

Note: CategoryIds are negative values, so Ascending order would put things like fish (Id=-4) before gem (Id=-2)


FilterTypes
Spoiler:  
Show

  • BagSize
Instructs ItemBags to only store matching items into particular bag size(s)
Expected value: One of the following bag sizes: "Small", "Medium", "Large", "Giant", "Massive", optionally prefixed with one of the following modifiers: "<", ">", "<=", ">=", "="
Example: "BagSize:>=Large" (This would match any size >= Large, which would be Large OR Giant OR Massive)
Remarks: This filter can be useful if you want larger bag sizes to be capable of storing more items. For example,
{
    ...
    "ItemFilters": [
"CategoryId:-5|CategoryId:-6",
"CategoryId:-5|!BagSize:Small"
    ]
    ...
}

This would allow the bag to store eggs (id=-5) and milks (id=-6), BUT milks cannot be stored in the Smallest bag size. (So Small bags only store eggs, and every other size stores eggs+milks)

  • IsVanillaItem
Matches items that were NOT added to the game by a mod.
Expected value: None
Example: "IsVanillaItem"
Remarks: To detect if an item is a vanilla item or not, ItemBags simply looks for an underscore in the item's Id. This is because mods usually name their item Ids in this format: "{ModId}_{ItemId}". If a mod doesn't use this naming convention, ItemBags could incorrectly detect it's items as if they were vanilla items.

  • FromMod
Matches items that were added to the game by a particular mod.
Expected value: The mod's UniqueId, found in the mod's manifest.json file.
Example: "FromMod:FlashShifter.StardewValleyExpandedCP"
Remarks: To detect if an item is from a particular mod, ItemBags checks to see if the item's Id starts with the mod's UniqueId. This is because mods usually name their item Ids in this format: "{ModId}_{ItemId}". If a mod doesn't use this naming convention, ItemBags won't be able to know that the item came from that mod. If a mod has multiple components, use the UniqueId of whichever component added the items to the game (usually the CP - Content Patcher portion of the mod).

  • HasMod
Checks if a given mod is installed
Expected value: The mod's UniqueId, found in the mod's manifest.json file. Can optionally be suffixed with "-{MinimumVersion}"
Example: "Rafseazz.RSVCP-2.5.17" (Checks if RSV version 2.5.17 or later is installed)

  • CategoryId
Matches items belonging to the specified Category Id.
Expected value: An integer representing the desired category Id. Category Ids can be found here. You can also specify several categories, separated by commas.
Examples: "CategoryId:-5", "CategoryId:-5,-6"
Remarks: Not all items have a valid category. I think the game just uses a value of zero for uncategorized items?

  • IsBigCraftable
Matches items that are BigCraftables.
Expected value: None
Example: "IsBigCraftable"
Remarks: Bags are only capable of storing BigCraftables or standard Objects. They can't store things like tools or equippables (hats, rings, boots, weapons etc). So if you negate this filter, it will only match standard Objects.

  • Quality
Matches items of a particular quality-level (Normal, Silver, Gold, Iridium)
Expected value: A valid quality, either defined by it's name ("normal", "silver", "gold", "iridium"), or defined by its internal integer value (0, 1, 2, or 4) (Yes, quality value of 4 means iridium. NOT 3. Don't ask me why)
Example: "Quality:Iridium"
Remarks: When processing an item, ItemBags will attempt to 'guess' if the item is available in multiple different qualities, or if the item can only be regular quality. It makes this guess based on the item's category. Categories like fish, eggs, milks, fruits, vegetables, flowers etc, are assumed to be available in all 4 qualities. While other items such as gems or minerals are assumed to only be available in 'normal' quality. If you use this filter to attempt to match non-regular qualities of an item that ItemBags assumes aren't available in non-regular qualities, then the item would not pass the filter. You can override which categories support quality-levels using the CategoryQualities json property (more details later in this article, in the Quality Levels section)

  • HasContextTag
Matches items that have a particular context tag in their metadata.
Expected value: The name of the context tag
Example: "HasContextTag:color_iridium"
Remarks: The wiki only lists some of the context tags, and mods can add their own unique context tags to their items as well. So this filter is more useful than it may seem at first glance. You can use the console command debug listtags to see the context tags on whatever item you're currently holding.

  • HasBuffs
Matches items that apply at least one buff when used.
Expected value: None
Example: "HasBuffs"
Remarks: Stamina/Health restorative effects are not a buff, so this filter doesn't necessarily match all food items.

  • IsDonatable
Matches items that can be donated to the museum.
Expected value: None
Example: "IsDonatable"
Remarks: This includes items that can be donated to the museum, or to the fossil island office on Ginger Island.

  • IsPendingDonation
Matches items that can be donated to the museum, but only if the item has not already been donated.
Expected value: None
Example: "IsPendingDonation"
Remarks: ItemBags only calculates this filter's matches when a save file is first loaded after launching the game. It does not dynamically update. So it won't reflect changes if you just donated an item, or if you load a different save file that has donated different items. In other words, re-launch the game to let ItemBags fully refresh the valid items.

  • QualifiedId filters: QualifiedId, QualifiedIdPrefix, QualifiedIdSuffix, QualifiedIdContains
These 4 filters are matched against the item's qualified Id (as in, the Id that includes the item type, such as '(BC)' for BigCraftables or '(O)' for standard objects.)
Expected value: The QualifiedId filter matches against an exactly-specified value. The Prefix filter looks for Ids that start with the given value. The Suffix filter looks for Ids that end with the given value. The Contains filter looks for Ids that contain the given text.
Example: "QualifiedIdContains:Fish"
Remarks: The values are case-sensitive

  • LocalId filters: LocalId, LocalIdPrefix, LocalIdSuffix, LocalIdContains
These 4 filters are matched against the item's UN-qualified Id (as in, the Id that does NOT include the item type, such as '(BC)' for BigCraftables or '(O)' for standard objects.)
Expected value: The LocalId filter matches against an exactly-specified value. The Prefix filter looks for Ids that start with the given value. The Suffix filter looks for Ids that end with the given value. The Contains filter looks for Ids that contain the given text.
Example: "LocalIdContains:Fish"
Remarks: The values are case-sensitive

  • Name filters: Name, NamePrefix, NameSuffix, NameContains
These 4 filters are matched against the item's name.
Expected value: The Name filter matches against an exactly-specified value. The Prefix filter looks for names that start with the given value. The Suffix filter looks for names that end with the given value. The Contains filter looks for names that contain the given text.
Example: "NameContains:Soup"
Remarks: The values are case-sensitive. The values are compared against the item's internal name, NOT the display name. This means that it doesn't use the localized item name - all names are their default English names.

  • DisplayName filters: DisplayName, DisplayNamePrefix, DisplayNameSuffix, DisplayNameContains
These 4 filters are matched against the item's DisplayName.
Expected value: The DisplayName filter matches against an exactly-specified value. The Prefix filter looks for DisplayNames that start with the given value. The Suffix filter looks for DisplayNames that end with the given value. The Contains filter looks for DisplayNames that contain the given text.
Example: "DisplayNameContains:Soup"
Remarks: The values are case-sensitive. The values are compared against the item's DisplayName instead of its InternalName. This means that it uses the item name in the current language rather than always using the English name.

  • Regex filters: InternalNameRegex, DisplayNameRegex, LocalIdRegex, QualifiedIdRegex
These 4 filters use a regular expression (regex) pattern string to match against either the item's InternalName, the DisplayName, the unqualified (LocalId) Id, or the qualified Id.
Expected value: A regex pattern string
Example: "DisplayNameRegex:^[A-C]"
Remarks:
Spoiler:  
Show
Regexes are a complex concept that is out of scope for this tutorial. You can learn more about them elsewhere on the internet. Here's a few examples of what they can do:

{
...
"ItemFilters": [
"CategoryId:-4",
"DisplayNameRegex:^[A-D]"
]
...
}


The regex pattern ^[A-D] matches text that begins with the letters A through D, so any display name starting with 'A', 'B', 'C', or 'D'

{
...
"ItemFilters": [
"CategoryId:-4",
"LocalIdRegex:^\\d{3}$"
]
...
}


The regex pattern ^\\d{3}$ matches text that contains exactly 3 digits (The \d matches any digit, 0-9, and the {3} modifier applies it 3 times in a row) (Note: We had to escape the backslash so that the json would parse. ^\d{3}$ would not be valid JSON). So this set of filters would match all fish (category=-4), that were added to the game before the 1.6 game update (because prior to 1.6, ItemIds were always numerical values, but after that they were switched to text values and newer fish use the fish's name in their Id)

Note: Regexes often use the vertical pipe character (|) but that character is currently reserved for logically OR-ing multiple filters together. If you need to use the '|' character in your regex, you will have to override the filter delimiter by adding a property to the json file called ItemFiltersDelimiter.

{
...
"ItemFilters": [
"CategoryId:-4",
"DisplayNameRegex:^(A|B|C)||DisplayNamePrefix:H"
],
"ItemFiltersDelimiter": "||",
...
}


In this example, the delimiter is overriden to "||" instead of just "|". So now the regex pattern (^(A|B|C|D)) can use single '|' characters without them being mistaken for a filter delimiter.




Limit / Offset
Spoiler:  
Show

The Limit setting determines the maximum number of items that a filter can match before it stops matching anything.
The Offset setting determines how many matched items a filter will skip before its matches are added to the result set.

You can apply a Limit and/or Offset by adding the ItemFiltersLimit property or ItemFiltersOffset property to the modded bag's .json file.

{
...
"ItemFilters": [
"CategoryId:-2"
],
"ItemFiltersLimit": 4,
"ItemFiltersOffset": 0,
...
}


This would normally match all gems (category=-2), but since the limit is set to 4, it only matches the first 4 gems it finds in the game's item database. If we changed the offset to 2, then it would still match 4 gems, but instead of matching the very first 4, it would match the 3rd, 4th, 5th, and 6th gems.

Limits and Offsets can be especially useful if you want to divide a bag up into multiple chunks. For example, suppose you wanted a bag that matched all fish, but you have a ton of mods that add fishes to the game. So a single bag for all fish might contain too many items for them to fit on screen. If you wanted to break it up into multiple bags, you might set the 1st bag to use Limit=100, Offset=0, then the 2nd bag uses Limit=100, Offset=100, the 3rd bag uses Limit=100, Offset=200 etc.

You can also apply a Limit and Offset directly to an individual filter, by suffixing the filter's name with a hyphen followed by the limit and offset, like so:
"CategoryId-4,0:-2"

CategoryId is the filter type
4,0 is the limit and offset
-2 is the value that the filter matches

"{FilterType}-{Limit},{Offset}:{Value}"

Here's a more complex example:

"ItemFilters": [
"!Quality:Iridium|CategoryId-5,0:-2",
"CategoryId:-2"
],


Don't ask me why you'd ever do this, but the above example would match all gems, except that it would exclude the iridium quality on the 1st 5 gems.

Note: If Limit is set to 0, it is implicitly treated as infinite



Quality levels
Spoiler:  
Show
When retrieving an item and checking if it passes the provided ItemFilters, ItemBags will attempt to 'guess' if the item is available in multiple different qualities, or if the item can only be regular quality. It makes this guess based on the item's category. Categories like fish, eggs, milks, fruits, vegetables, flowers etc, are assumed to be available in all 4 qualities. While other items such as gems or minerals are assumed to only be available in 'normal' quality. You can override this logic by providing a value for the CategoryQualities json property in the modded bag's .json file.

For example, suppose you installed a mod that allowed gems to be available in silver/gold/iridium qualities. If you then wanted to use ItemFilters to make a modded bag that can store all gem items, you could do the following:

{
    ...
    "ItemFilters": [
        "CategoryId:-2"
    ],
"CategoryQualities": "-2:true"
    ...
}


"-2:true" tells ItemBags that the category Id of -2 (Gems) DOES support multiple quality values. So the format is: "{CategoryId}:{OverrideValue}" where the OverrideValue can either be 'true' or 'false'. You can override multiple categories by separating them with a comma, such as "-2:true,-4:false"



Debugging
Spoiler:  
Show
Use the console command refresh_modded_bags to update your bags at runtime without needing to fully re-launch the game for the changes to take effect. This command does not completely reload the modded bags, it only refreshes the settings of modded bags that have already been loaded into the game. So if a new modded bag file is added to the assets/modded bags folder, it won't be loaded until relaunching the game. But if an existing modded bag file is modified, this command will update its settings such as what items it can store or its menu options.


Changelog
Spoiler:  
Show
  • 3.1.0-beta1:
Added ItemFilters and CategoryQualities json properties

  • 3.1.0-beta2:
Fixed HasContextTag filter

  • 3.1.0-beta3:
Fixed bug where BigCraftables could show up in the result set when they weren't supposed to

  • 3.1.0-beta4:
Bugfix FromMod filter
Improve BagSize filter to support the following prefixes: '<', '>', '<=', '>=', '='
Add HasMod filter

  • 3.1.0-beta5:
Improve FromMod filtering to handle this naming convention: "{ModId}.{ItemId}"
Items in bag menus are no longer grouped by quality unless they support all 4 quality values being placed into the bag
Quality ItemFilter value is now case-insensitive
HasContextTag filter now handles tags added dynamically after item creation (such as "HasContextTag:fish_difficulty_easy")

  • 3.1.0-beta6:
Improve CategoryId filter to allow multiple comma-separated values, such as CategoryId:-5,-6 to match either category
Add refresh_modded_bags console command to aid with testing so you can see your changes without relaunching the game
Improved error-logging for invalid filters

  • 3.1.0-beta7:
Add DisplayName filters
Add Limit/Offset settings
Add Regex filters
Add settings to control item sorting order

Article information

Added on

Edited on

Written by

SlayerDharok

41 comments

  1. Shaeh
    Shaeh
    • member
    • 0 kudos
    would it be possible to add items pending shipment as a filter?
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Sure but that could match a ton of items which may not fit on the UI. If I add this filter and you use it, you may need to utilize the Limit and Offset settings to divide it into multiple bags
  2. wibbelkind
    wibbelkind
    • member
    • 0 kudos
    Trying to set up a Cornucopia Artisan Goods + Ingredients bag and cannot for the life of me figure out why this bag shows up completely empty:

    {
      "IsEnabled": true,
      "ModUniqueId": "SlayerDharok.Item_Bags",
      "BagId": "d2741cd3-6c98-416b-5a59-51ca88672751",
      "BagName": "Cornucopia Artisan Goods Bag",
      "BagDescription": "A bag for storing items of specific category(s)",
      "IconTexture": "SpringObjects",
      "IconPosition": {
        "X": 0,
        "Y": 0,
        "Width": 0,
        "Height": 0
      },
     [...]
      "ItemFilters": [
            "FromMod:Cornucopia.ArtisanMachines|FromMod:Cornucopia.MoreCrops|FromMod:Cornucopia.MoreFlowers",
            "CategoryId:-5|CategoryId:-6|CategoryId:-25|CategoryId:-26|CategoryId:-27"
        ]
    }
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      The FromMod filter expects ItemIds to follow this naming convention: "{ModId}_{ItemId}" or "{ModId}.{ItemId}"

      The cornucopia mods seem to name their items like this instead: "Cornucopia_{ItemId}" so they aren't detected.
      You'd have to use a LocalIdPrefix filter instead, such as: "LocalIdPrefix:Cornucopia_"

      Alternatively you could try using the HasContextTag filter since it seems like those mods add their own context tags that identify the mod, such as "HasContextTag:modid_cornucopia.morecrops"
    2. wibbelkind
      wibbelkind
      • member
      • 0 kudos
      Ah, thank you! Will try and report back,
    3. passersby10086
      passersby10086
      • premium
      • 45 kudos
      After experiments, mods like cornucopia can be directly written as FromMod:Cornucopia, and this will work
    4. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      FromMod:Cornucopia would match any cornucopia mods, not just a specific one like MoreCrops or MoreFlowers
  3. SlayerDharok
    SlayerDharok
    • premium
    • 42 kudos
    Just a heads up: The new version 3.1.0-beta6 has a new console command, refresh_modded_bags, to immediately see your changes without needing to re-launch the game. This can help with testing and fine-tuning your bags. You can even use it while a bag's menu is open and the changes will appear immediately.
  4. wibbelkind
    wibbelkind
    • member
    • 0 kudos
    Okay I'm reorganising my Modded Bags and I'm trying to figure out how to fiilter stuff like the Corals, Nautilus Shells, Sea Urchins... They don't have a category so how do I catch them in my modded bag...?
    1. wibbelkind
      wibbelkind
      • member
      • 0 kudos
      I figured to add them with "HasContextTag:forage_item" but now I need to add  Category Qualities for them as well - how?
    2. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Nautilus Shell (Id="(O)392"), Coral (Id="(O)393"), and Sea Urchin (Id="(O)397") all belong to category Id=-23. If you just wanted those 3 items, you could explicitly filter for those Ids: "QualifiedId:(O)392|QualifiedId:(O)393|QualifiedId:(O)397"

      Or filter for the category: "CategoryId:-23"
      Or filter for a a context tag they share in common: "HasContextTag:forage_item_beach"
    3. wibbelkind
      wibbelkind
      • member
      • 0 kudos
      Yeah, I got them with the context tag. I'll see if I can add the category qualities for all of them with the ID-23
  5. welterusten
    welterusten
    • member
    • 2 kudos
    Did more testing and it looks like "HasContextTag" doesn't work with the context tags added automatically by the game. I was trying to make a bag that holds artifacts added by mods. Per the wiki, each object-type item gets a item_type_<type> context tag.

      "ItemFilters": [
        "!IsVanillaItem",
        "HasContextTag:item_type_arch"
      ]

    Also the "Quality" item filter feels weird since even if a bag only accepts iridium quality (for example), the bag will still show all qualities regardless. I remember reading about the Qualities being hardcoded or something so I am guessing this is intentional?
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Hmm yeah, it looks like the item metadata doesn't include every context tag. Looks like the only way to get a complete list of tags is to create a temporary instance of the item to read the data from, rather than reading from the item's metadata.

      The quality filter was mainly intended to be used with menus that set "GroupByQuality" to false. Right now, if GroupByQuality is true, then any item that supports multiple quality values is being displayed in the grouped portion of the menu. I'll change this so that it only groups items that support all 4 item qualities.

      Also there's currently a bug with the quality filter where it expects a lowercase value (I.E. "Quality:Gold" wouldn't work, currently needs "Quality:gold"). Fixing that in next update.
    2. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Dynamic tags are now accounted for in version 3.1.0-beta5
    3. welterusten
      welterusten
      • member
      • 2 kudos
      Works like a charm. Thank you so much for all the work you're putting into this!
  6. passersby10086
    passersby10086
    • premium
    • 45 kudos
    The Negation Operator does have some problems. When I tried to use it to exclude some types of items, it didn't work. I'll try"! CategoryId:-4|! CategoryId:-7|! CategoryId:-23|! CategoryId:-74|! CategoryId:-75|! CategoryId:-79|! CategoryId:-80|! CategoryId:-81" Excluded items of these types, but in the end they were still added
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      There should not be a space after the negation operator.
      "! CategoryId:-7" should be "!CategoryId:-7" for example.

      Also, are you logically OR-ing those category filters? If so, it wouldn't make much sense. If you logically OR two negated filters that match mutually-exclusive values, then the result set would be every single item. For example, "(NOT fish OR NOT fruit)" would match everything, because there is no such item that is both a fish and a fruit.
    2. passersby10086
      passersby10086
      • premium
      • 45 kudos
      There are no Spaces. It can run normally in the positive direction. However, the negative term cannot take effect
    3. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      What filter are you using? Category filtering seems to be working fine for me
    4. passersby10086
      passersby10086
      • premium
      • 45 kudos
      Based on the filtering module, reverse filter the item types
    5. passersby10086
      passersby10086
      • premium
      • 45 kudos
        "ItemFilters": [  "FromMod:FlashShifter.StardewValleyExpandedCP" ,  "!CategoryId::0|!CategoryId::-2|!CategoryId::-5|!CategoryId::-8|!CategoryId::-17|!CategoryId::-18|!CategoryId::-23|!CategoryId::-26|!CategoryId::-27|!CategoryId::-28|!CategoryId::-96"    ],
    6. passersby10086
      passersby10086
      • premium
      • 45 kudos
        "ItemFilters": [  "FromMod:FlashShifter.StardewValleyExpandedCP" ,  "!CategoryId::0|!CategoryId::-2|!CategoryId::-5|!CategoryId::-8|!CategoryId::-17|!CategoryId::-18|!CategoryId::-23|!CategoryId::-26|!CategoryId::-27|!CategoryId::-28|!CategoryId::-96"    ],
  7. welterusten
    welterusten
    • member
    • 2 kudos
    Can the ItemFilters json property be used for the bagconfig.json or is it only available for modded bag?
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      It's only for modded bags
  8. passersby10086
    passersby10086
    • premium
    • 45 kudos
    The situation where the module id could not be recognized has been resolved. However, if the item types continue to be filtered on the basis of recognizing the module id, such as
    "ItemFilters": [
    "FromMod:FlashShifter.StardewValleyExpandedCP"
    "CategoryId:-4"
    ],
    An error will occur

    The errors are as follows
    [Item Bags] Error while loading modded bag json files: Can't parse JSON file at C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\ItemBags\assets\Modded Bags\Stardew Valley Expanded Fish Bag.json. This doesn't seem to be valid JSON.

    Technical details: After parsing a value an unexpected character was encountered: ". Path 'ItemFilters[0]', line 130, position 2.

    Newtonsoft.Json.JsonReaderException: Can't parse JSON file at C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\ItemBags\assets\Modded Bags\Stardew Valley Expanded Fish Bag.json. This doesn't seem to be valid JSON.

    Technical details: After parsing a value an unexpected character was encountered: ". Path 'ItemFilters[0]', line 130, position 2.
       at StardewModdingAPI.Toolkit.Serialization.JsonHelper.ReadJsonFileIfExists[TModel](String fullPath, TModel& result) in /home/pathoschild/git/SMAPI/src/SMAPI.Toolkit/Serialization/JsonHelper.cs:line 86

       at StardewModdingAPI.Framework.ModHelpers.DataHelper.ReadJsonFile[TModel](String path) in /home/pathoschild/git/SMAPI/src/SMAPI/Framework/ModHelpers/DataHelper.cs:line 50

       at ItemBags.ItemBagsMod.LoadModdedBags() in
    C:\Programming\Source\Personal\SDV\Public\ItemBags\ItemBags\ItemBagsMod.cs:line 409
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      That JSON is missing a comma at the end of the first filter

      "ItemFilters": [
      "FromMod:FlashShifter.StardewValleyExpandedCP",
      "CategoryId:-4"
      ],
    2. passersby10086
      passersby10086
      • premium
      • 45 kudos
      This is what I copied from the article, which means you have to revise the article
    3. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Okay, it's been edited now
  9. neelcat
    neelcat
    • member
    • 0 kudos
    Hello! I'm having some troubles using the negating operation. Here's the SMAPI error:

    [Item Bags] Error while loading modded bag json files: Can't parse JSON file at /Users/embergamer/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/expansions/ItemBags/assets/Modded Bags/emberonis_EisforEggs.json. This doesn't seem to be valid JSON.Technical details: After parsing a value an unexpected character was encountered: ". Path 'ItemFilters[0]', line 138, position 1.Newtonsoft.Json.JsonReaderException: Can't parse JSON file at /Users/embergamer/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/expansions/ItemBags/assets/Modded Bags/emberonis_EisforEggs.json. This doesn't seem to be valid JSON.Technical details: After parsing a value an unexpected character was encountered: ". Path 'ItemFilters[0]', line 138, position 1.   at StardewModdingAPI.Toolkit.Serialization.JsonHelper.ReadJsonFileIfExists[TModel](String fullPath, TModel& result) in E:\source\_Stardew\SMAPI\src\SMAPI.Toolkit\Serialization\JsonHelper.cs:line 86   at StardewModdingAPI.Framework.ModHelpers.DataHelper.ReadJsonFile[TModel](String path) in E:\source\_Stardew\SMAPI\src\SMAPI\Framework\ModHelpers\DataHelper.cs:line 50   at ItemBags.ItemBagsMod.LoadModdedBags() in C:\Programming\Source\Personal\SDV\Public\ItemBags\ItemBags\ItemBagsMod.cs:line 409

    And here's what I added into my JSON file, copy/pasted from the tutorial and then edited (items section left in for context):

     "Items": [],
      "ItemCategories": {
          "Small": [],
          "Medium": [],
          "Large": [],
          "Giant": [],
          "Massive": []
      },
      
      "ItemFilters": [
          "!FromMod:UncleArya.ResourceChickens"
          "CategoryId:-5"
         ]
    }

    If I add a comma after the !FromMod section, the JSON loads, but the resulting bag just shows items from the mod. I've also toyed a little with using the | in test bags, and that hasn't worked either. But so far I've had no issues with modded bags that only use a single filter, so that's good!
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Are you using the beta4 version? FromMod filter was fixed earlier today
    2. neelcat
      neelcat
      • member
      • 0 kudos
      I just did a fresh reinstall and checked the manifest as well just to be 100% sure and I'm definitely using the beta4 version. Normal FromMod filters work, but the ! prefix doesn't seem to be doing anything. 
    3. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      It looks like that mod (ResourceChickens) doesn't use the naming convention "{ModId}_{ItemId}" for their Ids (They instead use a period as the delimiter instead of underscore, "{ModId}.{ItemId}") so the FromMod filter currently isn't recognizing them. I'll improve the filter to detect this format as well, but in the meantime you can change this filter:
      "!FromMod:UncleArya.ResourceChickens"
      To this:
      "!LocalIdPrefix:UncleArya.ResourceChickens."
      And it should be able to correctly identify that mod's items.
    4. neelcat
      neelcat
      • member
      • 0 kudos
      Thank you!! That worked <3
  10. passersby10086
    passersby10086
    • premium
    • 45 kudos
    It doesn't seem to have taken effect
    1. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      You're using the latest beta version? Does your SMAPI console window show any errors? If not, what settings are you using for the bag?
    2. passersby10086
      passersby10086
      • premium
      • 45 kudos
      I'm sure it's the latest test version. The console is very normal and there are no abnormalities. Below are the files of my bag

      {  "IsEnabled": true, 
      "ModUniqueId": "FlashShifter.StardewValleyExpandedCP", 
      "BagId": "a12c1fcb-9220-e0a8-420e-0e4a1aeb3d64", 
      "BagName": "Stardew Valley Expanded Fish Bag", 
      "BagDescription": "A bag for storing items belonging to Stardew Valley Expanded Fish ", 
      "IconTexture": "SpringObjects", 
      "IconPosition": {    "X": 0,    "Y": 0,    "Width": 0,    "Height": 0  }, 
      "Prices":{   
      "Small": 2000,   
      "Medium": 5000,   
      "Large": 20000,   
      "Giant": 50000,   
      "Massive": 100000 
      }, 
      "Capacities": {   
      "Small": 30,   
      "Medium": 99,   
      "Large": 300,   
      "Giant": 999,   
      "Massive": 9999 
      }, 
      "SizeSellers": {   
      "Small": [     " Willy"    ],   
      "Medium": [      " Willy"    ],   
      "Large": [      " Willy"    ],   
      "Giant": [      " Willy"    ],   
      "Massive": [      " Willy"    ]  }, 
      "SizeMenuOptions": {   
      "Small": {     
      "GroupByQuality": true,     
      "InventoryColumns": 12,     
      "InventorySlotSize": 64,     
      "GroupedLayoutOptions": {       
      "GroupsPerRow": 5,       
      "ShowValueColumn": true,       
      "SlotSize": 64     
      },     
      "UngroupedLayoutOptions": {       
      "Columns": 12,       
      "LineBreakIndices": [],       
      "LineBreakHeights": [],       
      "SlotSize": 64     
      }   
      },   
      "Medium": {     
      "GroupByQuality": true,     
      "InventoryColumns": 12,     
      "InventorySlotSize": 64,     
      "GroupedLayoutOptions": {       
      "GroupsPerRow": 5,       
      "ShowValueColumn": true,       
      "SlotSize": 64     
      },     
      "UngroupedLayoutOptions": {       
      "Columns": 12,       
      "LineBreakIndices": [],       
      "LineBreakHeights": [],       
      "SlotSize": 64     
      }   
      },   
      "Large": {     
      "GroupByQuality": true,     
      "InventoryColumns": 12,     
      "InventorySlotSize": 64,     
      "GroupedLayoutOptions": {       
      "GroupsPerRow": 5,       
      "ShowValueColumn": true,       
      "SlotSize": 64     
      },     
      "UngroupedLayoutOptions": {       
      "Columns": 12,       
      "LineBreakIndices": [],       
      "LineBreakHeights": [],       
      "SlotSize": 64     
      }   
      },   
      "Giant": {     
      "GroupByQuality": true,     
      "InventoryColumns": 12,     
      "InventorySlotSize": 64,     
      "GroupedLayoutOptions": {       
      "GroupsPerRow": 5,       
      "ShowValueColumn": true,       
      "SlotSize": 64     
      },     
      "UngroupedLayoutOptions": {       
      "Columns": 12,       
      "LineBreakIndices": [],       
      "LineBreakHeights": [],       
      "SlotSize": 64     
      }   
      },   
      "Massive": {     
      "GroupByQuality": true,     
      "InventoryColumns": 12,     
      "InventorySlotSize": 64,     
      "GroupedLayoutOptions": {       
      "GroupsPerRow": 5,       
      "ShowValueColumn": true,     
        "SlotSize": 64     
      },     
      "UngroupedLayoutOptions": {       
      "Columns": 12,       
      "LineBreakIndices": [],       
      "LineBreakHeights": [],       
      "SlotSize": 64     
      }   

      }, 
      "Items": [ ], 
      "ItemFilters": [ 
      "FromMod:FlashShifter.StardewValleyExpandedCP" 
        ], 
      }
    3. SlayerDharok
      SlayerDharok
      • premium
      • 42 kudos
      Fixed. Just uploaded version 3.1.0-beta4