I'm assuming you mean specifically with this game/engine? Working with JSON files is very common, especially to read from to get data. I guess, like I said, I am missing some key concepts in regard to the VS API. To be clear, I am not looking to make a patch/JSON mod, I am using .NET as I'll have to make a GUI, etc.
My main goal right now is to programmatically get a list of all possible bed blocks, to then add logic/GUI to interaction with one. I could do something like:
serverAPI.World.GetBlock(new AssetLocation("bed-hay-head-north")).BlockId;
serverAPI.World.GetBlock(new AssetLocation("bed-hay-head-south")).BlockId;
//repeat for every bed type and direction
Instead of doing this, my idea was to read the JSON file for beds and extract the values in "variantgroups" and "shapebytype", and do some string manipulation (in .NET, not modifying the JSON, to clarify) and add all of them to an array for later event handling, something like:
// class field
private List<int> bedIdentifiers;
// [...]
public override void StartServerSide(ICoreServerAPI api)
{
base.StartServerSide(api);
string bedJson; // get bed.json here and use the values in it for the following lists
List<string> bedTypes = new List<string>(); // populate with types from JSON file, i.e., "wood", "hay", etc.
List<string> bedParts = new List<string>{ "head", "feet" };
List<string> directions = new List<string>{"north", "east", "south", "west"};
foreach (string bedType in bedTypes)
{
foreach (string direction in directions)
{
foreach (string bedPart in bedParts)
{
// compile bed array
bedIdentifiers.Add(serverAPI.World.GetBlock(new AssetLocation($"bed-{bedType}-{bedPart}-{direction}")).BlockId);
}
}
}
}
Might seem like a ridiculous way to go about this, but if more bed types were added, the mod wouldn't work properly. Hope that was clearer, and I hope there's an easier way to do this via API!