feat: blockstates

still a work in progress
This commit is contained in:
Fireblade
2026-05-02 15:14:48 -04:00
parent fc35ef155b
commit d89fadff68
80 changed files with 2249 additions and 2 deletions
@@ -0,0 +1,35 @@
#include "BlockStateDecoderRegistry.h"
#include <unordered_map>
#include <mutex>
namespace BlockStateDecoderRegistry {
static std::unordered_map<int, DecoderFn> *g_map = nullptr;
static std::mutex g_mapMutex;
static void ensureMap()
{
if (!g_map) g_map = new std::unordered_map<int, DecoderFn>();
}
void registerDecoder(int tileId, DecoderFn fn)
{
std::lock_guard<std::mutex> l(g_mapMutex);
ensureMap();
(*g_map)[tileId] = fn;
}
std::wstring decode(int tileId, int composite)
{
std::lock_guard<std::mutex> l(g_mapMutex);
ensureMap();
auto it = g_map->find(tileId);
if (it == g_map->end()) return L"";
try {
return it->second(composite);
} catch (...) {
return L"";
}
}
}