Food Effects

Food Effects

173k Downloads

RFC: Config overhaul.

SwanX1 opened this issue · 8 comments

commented

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

commented

Related to: #6

commented

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

commented

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!

commented

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 = []
commented

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!

commented

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! 👍

commented

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

commented

This is outdated.