mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-06-04 03:54:31 +00:00
feat(items): add managed custom item callbacks and native pickaxe support
Introduce a managed custom item API with mine-block callbacks and cancellation semantics, plus native runtime support for registering pickaxe items. Key changes: - add WeaveLoader.API Item base/PickaxeItem and dispatcher plumbing - register managed item instances in ItemRegistry - add native export for pickaxe registration and wire through GameObjectFactory - resolve/hook item mineBlock paths (ItemInstance/Item/DiggerItem) and dispatch to managed host - expose managed OnItemMineBlock entry in WeaveLoader.Core and DotNetHost - add Ruby Pickaxe example item + placeholder texture - keep logger usable even before managed handler setup via native fallback
This commit is contained in:
@@ -106,7 +106,8 @@ int native_register_item(
|
||||
ModStrings::Register(descId, wName.c_str());
|
||||
}
|
||||
|
||||
if (!GameObjectFactory::CreateItem(id, maxStackSize, wIcon.empty() ? nullptr : wIcon.c_str(), descId))
|
||||
if (!GameObjectFactory::CreateItem(id, maxStackSize, maxDamage,
|
||||
wIcon.empty() ? nullptr : wIcon.c_str(), descId))
|
||||
{
|
||||
LogUtil::Log("[WeaveLoader] Warning: failed to create game Item for '%s' id=%d", namespacedId, id);
|
||||
}
|
||||
@@ -114,6 +115,44 @@ int native_register_item(
|
||||
return id;
|
||||
}
|
||||
|
||||
int native_register_pickaxe_item(
|
||||
const char* namespacedId,
|
||||
int tier,
|
||||
int maxDamage,
|
||||
const char* iconName,
|
||||
const char* displayName)
|
||||
{
|
||||
if (!namespacedId) return -1;
|
||||
|
||||
int id = IdRegistry::Instance().Register(IdRegistry::Type::Item, namespacedId);
|
||||
if (id < 0)
|
||||
{
|
||||
LogUtil::Log("[WeaveLoader] Failed to allocate pickaxe item ID for '%s'", namespacedId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
LogUtil::Log("[WeaveLoader] Registered pickaxe item '%s' -> ID %d (tier=%d, durability=%d)",
|
||||
namespacedId, id, tier, maxDamage);
|
||||
|
||||
std::wstring wIcon = Utf8ToWide(iconName);
|
||||
|
||||
int descId = -1;
|
||||
if (displayName && displayName[0])
|
||||
{
|
||||
descId = ModStrings::AllocateId();
|
||||
std::wstring wName = Utf8ToWide(displayName);
|
||||
ModStrings::Register(descId, wName.c_str());
|
||||
}
|
||||
|
||||
if (!GameObjectFactory::CreatePickaxeItem(id, tier, maxDamage,
|
||||
wIcon.empty() ? nullptr : wIcon.c_str(), descId))
|
||||
{
|
||||
LogUtil::Log("[WeaveLoader] Warning: failed to create native PickaxeItem for '%s' id=%d", namespacedId, id);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
int native_allocate_description_id()
|
||||
{
|
||||
return ModStrings::AllocateId();
|
||||
|
||||
Reference in New Issue
Block a user