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
This commit is contained in:
Jacobwasbeast
2026-03-06 15:11:53 -06:00
commit de22a24100
45 changed files with 2489 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
namespace LegacyForge.API.Entity;
/// <summary>
/// Fluent builder for defining entity properties.
/// </summary>
public class EntityDefinition
{
internal float WidthValue = 0.6f;
internal float HeightValue = 1.8f;
internal int TrackingRangeValue = 80;
public EntityDefinition Width(float width) { WidthValue = width; return this; }
public EntityDefinition Height(float height) { HeightValue = height; return this; }
public EntityDefinition TrackingRange(int range) { TrackingRangeValue = range; return this; }
public EntityDefinition Size(float width, float height) { WidthValue = width; HeightValue = height; return this; }
}

View File

@@ -0,0 +1,38 @@
namespace LegacyForge.API.Entity;
/// <summary>
/// Represents an entity type that has been registered with the game engine.
/// </summary>
public class RegisteredEntity
{
public Identifier StringId { get; }
public int NumericId { get; }
internal RegisteredEntity(Identifier id, int numericId)
{
StringId = id;
NumericId = numericId;
}
}
/// <summary>
/// Entity registration via the LegacyForge registry.
/// Accessed through <see cref="Registry.Entity"/>.
/// </summary>
public static class EntityRegistry
{
public static RegisteredEntity Register(Identifier id, EntityDefinition definition)
{
int numericId = NativeInterop.native_register_entity(
id.ToString(),
definition.WidthValue,
definition.HeightValue,
definition.TrackingRangeValue);
if (numericId < 0)
throw new InvalidOperationException($"Failed to register entity '{id}'.");
Logger.Debug($"Registered entity '{id}' -> numeric ID {numericId}");
return new RegisteredEntity(id, numericId);
}
}