Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ResourceRevamp] Item Name Field #78

Open
Tracked by #76
AsherGlick opened this issue Jul 16, 2022 · 0 comments
Open
Tracked by #76

[ResourceRevamp] Item Name Field #78

AsherGlick opened this issue Jul 16, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@AsherGlick
Copy link
Owner

Right now we have an awkward ordered dictionary of items in the resource list. This works purely because yaml, as a serialized data structure, is ordered. As a result we can parse it into code in an ordered manner. However if some other application parsed the file and then wrote the output, it may re-order the elements. Which is completely within-spec for the yaml file.

Additionally, searching for a particular item is very difficult in the current schema. If I am trying to find the Stone element I might search for Stone:, but that will return all the instances where stone is being used as a requirement Stone: -1. Even searching for two leading spaces will cause the same elements to be found. The only way to guarantee finding the item is by searching for the beginning of a line as well

r/$  Stone:/

Instead of using Stone as the key for a dictionary it should instead be a field within the element and the container should become an ordered array.

resources:
  Stone:
    recipes:
    - recipe_type: Raw Resource
    - output: 1
      recipe_type: Smelting
      requirements:
        Cobblestone: -1
        Fuel: -1

  Granite:
    recipes:
    - recipe_type: Raw Resource
    - output: 1
      recipe_type: Crafting
      requirements:
        Diorite: -1
        Nether Quartz: -1

Becomes

resources:
  - name: Stone
    recipes:
    - recipe_type: Raw Resource
    - output: 1
      recipe_type: Smelting
      requirements:
        Cobblestone: -1
        Fuel: -1

  - name: Granite
    recipes:
    - recipe_type: Raw Resource
    - output: 1
      recipe_type: Crafting
      requirements:
        Diorite: -1
        Nether Quartz: -1

This allows us to preserve the order of the items regardless of what parser is being used, and it gives us a much simpler way of finding the item we are looking for by searching for name: Stone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant