anegostudios / VintageStory-Issues

Vintage Story's public issue tracker for reporting bugs, crashes and the like

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server side AfterActiveSlotChanged is broken

maltiez2 opened this issue · comments

Game Version

1.19.0-pre.6

Platform

Windows

Modded

Modded

SP/MP

Singleplayer

Description

Vintagestory.Server.ServerEventManager.TriggerAfterActiveSlotChanged(IServerPlayer player, int fromSlot, int toSlot) calls InvokeSafeCancellable instead of InvokeSafe when invoking AfterActiveSlotChanged that results in game trying to cast Action<IServerPlayer, ActiveSlotChangeEventArgs> to Func<IServerPlayer, ActiveSlotChangeEventArgs, EnumHandling> that results in crash.

How to reproduce

Add handler to ICoreServerAPI.Event.AfterActiveSlotChanged

Screenshots

image
image

Logs

6.1.2024 00:26:40 [Error] Exception: Unable to cast object of type 'System.Action`2[Vintagestory.API.Server.IServerPlayer,Vintagestory.API.Common.ActiveSlotChangeEventArgs]' to type 'Vintagestory.API.Common.Func`3[Vintagestory.API.Server.IServerPlayer,Vintagestory.API.Common.ActiveSlotChangeEventArgs,Vintagestory.API.Common.EnumHandling]'.
at Vintagestory.API.Common.EventHelper.<>c__DisplayClass1_0`2.<InvokeSafeCancellable>b__0(Delegate handler) in VintagestoryLib\Common\API\EventHelper.cs:line 32
at Vintagestory.API.Common.EventHelper.InvokeSafeCancellable(Delegate ev, ILogger exceptionLogger, String eventName, Func`2 mapper) in VintagestoryLib\Common\API\EventHelper.cs:line 69  ```

Duplicate of #3172