altmp / coreclr-module

CoreClr (.NET Core Common Language Runtime) community made module
MIT License
17 stars 8 forks source link

IPlayerFactory crash #16

Closed dGxxxx closed 7 months ago

dGxxxx commented 7 months ago
public class BetterLocalPlayer : LocalPlayer
{
    public string Test = "test";
    public BetterLocalPlayer(ICore core, IntPtr nativePointer, uint id) : base(core, nativePointer, id)
    {
    }
}
public class BetterLocalPlayerFactory : IPlayerFactory 
{
    public IPlayer Create(ICore core, IntPtr entityPointer, uint id) 
    {
        return new BetterLocalPlayer(core, entityPointer, id);
    }

    public ILocalPlayer GetLocalPlayer(ICore core, IntPtr localPlayerPointer, uint id) 
    {
        return new BetterLocalPlayer(core, localPlayerPointer, id);
    }
}
public override IPlayerFactory GetPlayerFactory()
    {
        return new BetterLocalPlayerFactory();
    }

This code crashes the client. No logs, nothing. Just crash.

Am i doing something wrong?

Doxoh commented 7 months ago

public IPlayer Create(ICore core, IntPtr entityPointer, uint id) { return new BetterLocalPlayer(core, entityPointer, id); }

this is not possible, u need a BetterPlayer class for this