infernalstudios / Food-Effects

Apache License 2.0
0 stars 0 forks source link

RFC: Config overhaul. #7

Closed SwanX1 closed 1 year ago

SwanX1 commented 2 years ago

Right now the config consists of two elements: eat_cookies_berries_fast and effects. My proposal is to change the entire config into a map (key->value data structure) of sorts.

# Current config
[General]
  eat_cookies_berries_fast = true

[[effects]]
  duration = 5.0
  item = "minecraft:steak"
  amplifier = 1
  effect = "minecraft:strength"

General only contains one config, and is really unextendable, which can be merged into each food itself, to make it more extendable. To add more than one effect to a food, you need to create multiple entries for that food, which can make the config disorganized.

# New config
["minecraft:steak"]
  eat_duration = 1
  saturation = 3
  hunger = 5

  [["minecraft:steak".effects]]
    effect = "minecraft:health"
    amplifier = 1
    duration = 1

["*"]
  eat_duration = 0.5

The new config only consists of item -> food data configurations. The food data configuration is as follows: any attributes to be changed are in their seperate fields, like eat_duration (in ticks), saturation, and hunger, then a seperate field effects, which lists the effects. Note that every field is optional, except for item.effects[].effect, which requires an effect identifier.

There is also a new wildcard (*) selector for items, in case you would like to change something globally. The non-wildcard-items take precedence, so you'd have to overwrite every customized food which you want to tweak, because the wildcard will not affect it.

These changes would warrant a major version change, which would bump the version number to 2.0.0

SwanX1 commented 2 years ago

Related to: #6

SwanX1 commented 2 years ago

@nekomaster1000 @Dariensg I'd like your opinions and approval on this.

Dariensg commented 2 years ago

It looks good to me honestly! This is what I was proposing in solution to #6.

The one change I might have, if possible, is that the wildcard effects all, including things with an existing entry, as long as the entry doesn't have that specific field set itself. So like, if you have baked potato with an effect set but no eat duration set, the wildcard eat duration would still affect that. But if carrot has a specific eat duration set, wildcard won't take precedence there. I'm not sure how possible this is, but it would make things easier for people that want to set a global eat duration, but also have effects for a large number of food.

The other question I have is what if people want a global effect on all food items but then also for individual food items to have specialized effects in addition to this? Would there be a good way to use a wildcard effect without it getting overwritten by the specialized effects. I know you could just add the wildcard effect to all the specialized arrays as well, but I'm just trying to think of ways to eliminate as much repetition and tedium as possible!

SwanX1 commented 2 years ago

The one change I might have, if possible, is that the wildcard effects all, including things with an existing entry, as long as the entry doesn't have that specific field set itself.

I had that idea, but I excluded it because it'd be confusing to code. I will accept this suggestion purely because someone else would like it.

The other question I have is what if people want a global effect on all food items but then also for individual food items to have specialized effects in addition to this?

The problem is that effects is a seperate (array) field for the item. It would be even more confusing to some people, and even when coding, because default behaviour would overwrite it (ref: previous suggestion). I think we should keep it so that it overwrites the wildcard effects. Some people may also want to not add the global effect to an item, so overriding it would be as simple as:

# Poison is applied to every food...
[["*".effects]]
  effect = "minecraft:poison"
  amplifier = 1
  duration = 15

# ...except a golden apple
["minecraft:golden_apple"]
  effects = []
Dariensg commented 2 years ago

Fair enough! So my first suggestion you'll take but not the second? I agree with you that it's good to have an override option, and that wouldn't be possible with the wildcard effects adding to all arrays!

nekomaster1000 commented 2 years ago

Some people may also want to not add the global effect to an item, so overriding it would be as simple as:

# Poison is applied to every food...
[["*".effects]]
  effect = "minecraft:poison"
  amplifier = 1
  duration = 15

# ...except a golden apple
["minecraft:golden_apple"]
  effects = []

I very much like this approach! Simple and straightforward to understand, it'd work very well! 👍

MattB70 commented 2 years ago

Of course you already know my vote :) 100% yes!

SwanX1 commented 1 year ago

This is outdated.