#Codecs and Data-driven systems?

9 messages · Page 1 of 1 (latest)

rose cliff
#

very new to modding- i have some generic programming experience that helps a bit and ive brushed up on java syntax before tackling this, but i kinda don't know where to begin with this yet so.

i'm trying to make some kind of data-driven system for player abilities, similar to how Origins or Palladium does things. i know sort of the basic idea is that i have to use codecs to parse json back and forth and ive read that doc page to the best of my abilities. however, im not quite sure where to go from here. my usual approach is to just start making stuff so i can mess around with it, but this concept is so broad with so many open questions that i feel i kind of need some help on this. like, how do i pull this information from a file inside of a datapack? how do i actually store whether or not the player has this ability file assigned to them? etc.
i can be more specific if necessary; id appreciate stuff being explained as basic as possible as this is practically my first real project 😭 honestly a pretty complicated thing to start out with, but im not too afraid of that as long as i understand it eventually

verbal sail
#

Can you describe precisely what you want to do? The more detail, the better.

#

Also, what Minecraft version are you targeting?

rose cliff
# verbal sail Can you describe precisely what you want to do? The more detail, the better.

1.21.1. the system im trying to accomplish is to be able to add a 'power' json file inside of a datapack. the power registers and can be given to a player (probably via command for now, though i figure thatd be the easy part). each power contains a list of abilities that point to ability types, and further values can be set depending on that ability type.
sorta the mockup of how id want this to function ideally:

{
  "name": "mod.power.pyrokinetic",
  "abilities": [
    {
      "type": "mod:fireball",
      "icon": "mod:ui/ability/pyrokinetic/fireball.png",
      "cooldown": 20,
      "range": 9
    },
    {
      "type": "mod:shield",
      "icon": "mod:ui/ability/pyrokinetic/fire_shield.png",
      "cooldown": 20,
      "particle": "flame"
    }
  ]
}

just sort of a basic example i thought up with fire powers or something. the ability type field wouldnt be able to be defined via datapack, itd just point towards things i register inside the mod. basically, just so i have a lot more control over values and can live tweak them as i see fit. theres a lot more i wanna do with this, but i feel like if i figure this out then the rest will be relatively easy to brute force myself

#

origins and palladium both do very similar things to this, but i wasnt having much luck looking at their source code because im very inexperienced overall

#

i know the basic idea is i want like, my power class to have a name parameter as a string and like an ability list as a map, and i want all these things to be codecs so that they can be parsed to/from json. but i dont really know what to do beyond that knowledge, like i dont know how to actually grab that information from a directory inside of a datapack and whatnot

#

i guess basically, right now i just want to learn how to grab like a boolean from some json file inside of a datapack

#

i think i could probably build off of that and learn the rest myself?

solid berry
#

Use a ResourceReloader (? I think that’s the correct name) to read the powers from json