#[KubeJS 7.2 Schema] Optional list that can accept a single item

5 messages · Page 1 of 1 (latest)

proud trellis
#

hello! im making an addon for Electrodynamics's wire_mill recipe (example) and struggling to make the byproducts an optional list, that can also be a single item.

currently, my key is as follows:

{
  "name": "itembi",
  "role": "output",
  "type": {
    "type": "list",
    "component": "kubejsvoltaic:probable_item",
    "can_write_self": true,
    "bounds": {
      "min": 0
    }
  },
  "function_names": ["itemBi", "itemByproducts"],
  "optional": {},
  "excluded": true
}

(kubejsvoltaic:probable_item is my custom component, and seeing how the basemod recipes don't error, it's probably good - changing it to item_stack does prompt errors from them)
yet, my current code throws Invalid component itembi: kubejsvoltaic:probable_item[?] - Component 'kubejsvoltaic:probable_item[?]' is not allowed to be empty!, despite the bounds seemingly allowing a minimum of 0 elements?
removing the key fixes any errors and allows custom recipes to be registered, so this is definitely the issue - any clues?

hollow crowBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

proud trellis
#

by "single item" i mean being able to .wire_mill_recipe(...).itemBi(Item.of(...)), instead of .itemBi([ Item.of(...) ]), requiring an array in the case of a single byproduct

proud trellis
#

ive decided to switch back to 7.1 in the meantime becaues i do doubt 7.2 will be released by the time im done with this, so ill have to make a custom list component irregardless, but i am still interested in this for the future

proud trellis
#

well, since 7.2 is out and i figured out how to do it, i should probably dig this thread back up
you don't need a nested bounds - putting a flat "min": 0 is enough:

{
  "name": "itembi",
  "role": "output",
  "type": {
    "type": "list",
    "component": "kubejsvoltaic:probable_item",
    "can_write_self": true,
    "min": 0
  },
  "function_names": ["itemByproducts"],
  "optional": [],
  "excluded": true
}

though, i can't seem to be able to get the max parameter to do anything... not that that's any sort of dealbreaker for me, personally