Culinaire icon indicating copy to clipboard operation
Culinaire copied to clipboard

Transfer tea flavors to datapack resources

Open Hugman76 opened this issue 2 years ago • 2 comments

Presentation

This PR aims at making the tea flavors part of data pack resources, instead of hardcoding them by:

  • Adding a resource reloader listener to stock tea flavors
  • Moving the tea potencies to the tea flavor configuration
    • Gloopy and glowing tea flavors only had one effect, so having multiple potencies was useless
  • Adding a tea effect registry
    • Currently contains culinaire:grant_effect, culinaire:clear_effect and culinaire:consume_item, which each their own codec parameters
    • A tea effect represent the algorithm that will get triggered upon the consumption of the tea bottle

Syntax

Let's take the file of the sour tea flavor as an example for what the PR is capable of right now: Location: culinaire/tea_flavors/sour.json Identifier: culinaire:sour File content:

{
  "color": 7238946,
  "potencies": [
    {
      "value": 1,
      "name": "tea_type.culinaire.sour.weak",
      "description": "tea_type.culinaire.sour.weak.description",
      "effects": [
        {
          "type": "culinaire:clear_effect",
          "mob_effect": "minecraft:poison"
        }
      ],
      "ingredients": "#culinaire:tea_ingredients/sour/weak",
      "brew_time": 400
    },
    {
      "value": 2,
      "name": "tea_type.culinaire.sour.normal",
      "description": "tea_type.culinaire.sour.normal.description",
      "effects": [
        {
          "type": "culinaire:clear_effect",
          "mob_effect": "minecraft:poison"
        },
        {
          "type": "culinaire:grant_effect",
          "mob_effect": "minecraft:instant_health"
        }
      ],
      "ingredients": "#culinaire:tea_ingredients/sour/normal",
      "brew_time": 800
    }
  ]
}

Objectives

Firstly, I wish to move ingredients and brew times over to proper recipes files, and make input/output customizable too, in case another mod wants to create a new tea-friendly item. Let's also add more parameters for maximum potency amount, paper/string ingredients

Currently, this PR will absolutely break all previous tea bags and tea bottles. I will later add a fix that will re-write NBT data correctly. This PR also has a bug where if a bottle exists with a flavor, and that flavor gets later deleted, the game will get very laggy, spam the console and probably break the entire tea system. We will disscuss whether or not we directly attach tea effects to the item stack's NBT, or if we make those outdated tea items' NBT data vanish altogether, making the items unusable. I think the first solution is to be preferred. Right now, I am not sure if tea flavors are correctly synced from server to client. I'll need to test this out and maybe ask a few friends. I have tried doing dynamic registering, but this was a totaly messy experience that I wish I did not do at all. Therefore, it is currently just collected as part of a generic id -> tea flavor set in the singular instance of TeaFlavorManager.

It is also worth noting that the ingredients key does not allow for item arrays yet, as RegistryCodecs.entryList() just likes to spit at my face and tells me that either the field needs to be a JSON array, or that the item registry is not accessible when it actually IS a JSON array. This is what the minecraft:glow_lichen feature configuration uses (feature.glow_lichen.can_be_placed_on), as an example. Maybe the reload listener gets fired too early? I don't know.

Hugman76 avatar Apr 03 '22 12:04 Hugman76