broese / mcbuild

A custom Minecraft client with advanced auto-building capabilities
26 stars 11 forks source link

Created routine that parses items.json and stores it in a database_t #29

Closed harbaughfan closed 5 years ago

harbaughfan commented 5 years ago

Totally expect heavy editing of this. The static array wastes memory, I'm just not as confident with linked lists. And I'm not sure how the tracking of the db in memory will happen. But this does parse the items.json, which at least is a start. I put the code into a new .c/.h file & added to the Makefile.

Example usage:

#include "mcp_database.h"
int main(int ac, char **av) {
    printf("MCBuild 3.0 for Minecraft 1.13.x Development Branch\n"
           "Multi-protocol support: 1.13.2 (404)\n");
    database_t db = load_database(404);
    int x = get_item_id( &db, "obsidian");
    const char *y = get_item_name_from_db( &db,42);
    printf(" Obsidian is %d \n #42 is %s \n ",x,y);
    return 0;

// OUTPUT:  
// Obsidian is 139
// #42 is stripped_acacia_log