feat(modloader): add item use and summon APIs

Add managed item use hooks, server-authoritative summon support, and side-aware use item context.

Include IdHelper mappings, example ruby wand usage, and related runtime/crash-handler updates.
This commit is contained in:
Jacobwasbeast
2026-03-07 19:54:52 -06:00
parent eabf8fe858
commit 0b4c87acbc
21 changed files with 1862 additions and 45 deletions

View File

@@ -23,6 +23,8 @@ static managed_entry_fn fn_PostInit = nullptr;
static managed_entry_fn fn_Tick = nullptr;
static managed_entry_fn fn_Shutdown = nullptr;
static managed_entry_fn fn_ItemMineBlock = nullptr;
static managed_entry_fn fn_ItemUse = nullptr;
static managed_entry_fn fn_EntitySummoned = nullptr;
static bool LoadHostfxr()
{
@@ -179,6 +181,8 @@ bool DotNetHost::Initialize()
ok &= resolve(L"Tick", &fn_Tick);
ok &= resolve(L"Shutdown", &fn_Shutdown);
ok &= resolve(L"OnItemMineBlock", &fn_ItemMineBlock);
ok &= resolve(L"OnItemUse", &fn_ItemUse);
ok &= resolve(L"OnEntitySummoned", &fn_EntitySummoned);
if (!ok)
{
@@ -236,6 +240,29 @@ int DotNetHost::CallItemMineBlock(const void* args, int sizeBytes)
return fn_ItemMineBlock(const_cast<void*>(args), sizeBytes);
}
int DotNetHost::CallItemUse(const void* args, int sizeBytes)
{
if (!fn_ItemUse || !args || sizeBytes <= 0)
return 0;
return fn_ItemUse(const_cast<void*>(args), sizeBytes);
}
void DotNetHost::CallEntitySummoned(int entityNumericId, float x, float y, float z)
{
if (!fn_EntitySummoned)
return;
struct EntitySummonedNativeArgs
{
int entityNumericId;
float x;
float y;
float z;
} native{ entityNumericId, x, y, z };
fn_EntitySummoned(&native, sizeof(native));
}
void DotNetHost::Cleanup()
{
}