Commit Graph

8 Commits

Author SHA1 Message Date
Jacobwasbeast
44fd4416e5 Fix creative inventory: inject mod items before TabSpec page count calculation
- Inject items before Original_CreativeStaticCtor so TabSpec constructors
  include mod items when calculating m_staticItems and m_pages
- Add UpdateTabPageCounts() to recalculate TabSpec page counts after
  staticCtor as safety measure (handles different binary layouts)
- Resolve specs symbol for TabSpec array access
- Add diagnostic logging for ItemInstance vtable, shared_ptr, vector sizes
2026-03-06 22:47:08 -06:00
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
Jacobwasbeast
336e037730 Fix block/item game object creation and texture fallback
- Add GameObjectFactory: create actual Tile/TileItem/Item objects via PDB symbols
- Fix IdRegistry ID ranges: BLOCK_MOD_START=174, ITEM_MOD_START=3000
- Add icon parameter to item registration (API, NativeInterop, NativeExports)
- Use protected (IEAA/MEAA) decorated names for Tile/Item constructors
- Lazy-dereference Material/SoundType pointers (NULL until staticCtor runs)
- CrashHandler: skip __debugbreak() from game exe so missing texture fallback runs
- ExampleMod: add .Icon("ruby") to item registration
2026-03-06 20:10:13 -06:00
Jacobwasbeast
7af64bf83c Resolve crash stack traces to PDB symbol names
- Add PdbParser::BuildAddressIndex() to build a sorted RVA->name table
  from public and module symbols before closing the PDB file
- Add PdbParser::FindNameByRVA() for O(log n) reverse lookup at crash time
- Update crash handler to resolve Minecraft.Client.exe addresses to
  decorated function names (e.g. Minecraft.Client.exe!?tick@Minecraft+0x30)
- Resolve the faulting address itself in the crash report header
2026-03-06 19:26:32 -06:00
Jacobwasbeast
17f3a03aa0 Add crash handler, game debug capture, timestamped logging, and logs/ directory
- Add vectored exception handler (CrashHandler) installed from DllMain to
  reliably catch crashes before game CRT/SEH can override it, with x64
  stack walking via RtlVirtualUnwind and re-entrancy protection
- Hook OutputDebugStringA to capture game debug output into game_debug.log
- Move all log files into a logs/ subdirectory (legacyforge.log,
  game_debug.log, crash.log)
- Add millisecond-precision timestamps to all log entries
- Replace all raw printf calls with LogUtil::Log across every source file
  for consistent timestamped, file-persisted logging
2026-03-06 19:19:33 -06:00
Jacobwasbeast
34177e1507 Add main menu overlay, creative inventory injection, mod discovery, logging, and Wine/Proton support
- Replace dbghelp with raw_pdb library for cross-platform PDB symbol resolution
- Add main menu branding overlay via C4JRender::Present hook
- Add creative inventory item injection from mods
- Add file-based logging (LogUtil) alongside console output
- Fix mod discovery with custom AssemblyLoadContext for proper type identity
- Add file dialog for game path selection in launcher
- Add CreativeTab enum and block/item creative tab assignment
- Unify build output to single ModLoader/build directory
2026-03-06 18:59:02 -06:00
Jacobwasbeast
65ef99fc11 Use exact decorated symbol names verified against Minecraft.Client.pdb
Verified all hook targets exist in the compiled game's PDB:
- ?MinecraftWorld_RunStaticCtors@@YAXXZ
- ?tick@Minecraft@@QEAAX_N0@Z
- ?init@Minecraft@@QEAAXXZ
- ?ExitGame@CConsoleMinecraftApp@@UEAAXXZ (replaces destroy which is inlined)

Minecraft::destroy/run_end/stop are not public symbols (likely inlined),
so the shutdown hook now targets CConsoleMinecraftApp::ExitGame instead.
2026-03-06 15:16:06 -06:00
Jacobwasbeast
de22a24100 Initial commit: LegacyForge mod loader for Minecraft Legacy Edition
SKSE-style external mod loader with zero game source modifications.
- LegacyForge.Launcher: C# console app that injects runtime DLL into game process
- LegacyForgeRuntime: C++ DLL with PDB symbol resolution, MinHook function hooking, and .NET CoreCLR hosting
- LegacyForge.Core: C# mod discovery and lifecycle management
- LegacyForge.API: Fabric-style mod API with namespaced string IDs, fluent property builders, and event system
- ExampleMod: Sample mod demonstrating block/item registration
2026-03-06 15:11:53 -06:00