Files
LegacyWeaveLoader/LegacyForge.API/Assets/AssetRegistry.cs
Jacobwasbeast 2280cb1192 Mod textures, display names, and atlas injection
Mod Atlas (ModAtlas.cpp/h):
- Build merged terrain.png and items.png from mod assets (blocks/*.png, items/*.png)
- Scan vanilla atlas for empty (fully transparent) cells; place mod textures only there
- Install merged atlases over game files before Minecraft::init; restore originals after
- Hook loadUVs to create SimpleIcon objects for mod textures
- Hook registerIcon to return mod icons when requested by name
- FixupModIcons: copy field_0x48 (source-image ptr) from vanilla icons after init

Mod Strings (ModStrings.cpp/h):
- Store mod display names by description ID
- Hook GetString to serve mod names for blocks/items

API changes:
- BlockProperties/ItemProperties: .Name(displayName), namespaced .Icon()
- NativeInterop: displayName params, native_allocate_description_id, native_register_string
- Registry.Assets for string registration
- Output: mods/LegacyForge.API/, mods/ExampleMod/ (per-mod folders)

Mod discovery:
- Scan mods/*/ for mod folders; load DLLs from each
- LegacyForge.API as mod in mods/LegacyForge.API/

ExampleMod:
- Ruby ore block and ruby item with custom textures and names
- Assets: blocks/ruby_ore.png, items/ruby.png, lang files
- Furnace recipe: ruby_ore -> ruby

Runtime: loadUVs, registerIcon, getResourceAsStream, GetString hooks; stb_image for PNG
2026-03-06 22:04:15 -06:00

28 lines
1.0 KiB
C#

namespace LegacyForge.API.Assets;
/// <summary>
/// Asset registration for mods. Use for language strings and (future) texture paths.
/// Block and item display names are typically set via BlockProperties.Name() and ItemProperties.Name().
/// Use this registry for additional strings (e.g. GUI labels, messages).
/// </summary>
public static class AssetRegistry
{
/// <summary>
/// Register a display string for a custom description ID.
/// Use native_allocate_description_id() to get an ID, then wire it to your custom UI/entity.
/// </summary>
public static void RegisterString(int descriptionId, string displayName)
{
NativeInterop.native_register_string(descriptionId, displayName ?? "");
}
/// <summary>
/// Allocate a new description ID for custom strings.
/// IDs are in the mod range (10000+) and are looked up via the GetString hook.
/// </summary>
public static int AllocateDescriptionId()
{
return NativeInterop.native_allocate_description_id();
}
}