AlexMog / Longship

Valheim Dedicated server Fixes, Optimizations and High-Level API
MIT License
29 stars 3 forks source link

[Bug] Pickup and DropItem events didn't work #19

Open AlexMog opened 3 years ago

AlexMog commented 3 years ago

As I was fearing, the inventory is managed on the client-side, I will see if I can manage a way to force inventories update and listen on these events.

If you have any ideas, do not hesitate !

More info: Pickup an item process (as I have understood by retro-engineering the code): When a player pickup an item: -> Humanoid.Pickup is called on client side -> Humanoid.Pickup calls ItemDrop.Pickup   -> If ItemDrop.CanPickup() returns true (that means that the client is the owner of this object (Client is the owner = the server leaves the responsibility of the status of that item to the client, it's not the server who controls it anymore))     -> The local inventory is updated with the item, the client destroys the item   -> Else     -> The client sends a "RequestOwn" packet (to ask the server for the ownership of this item) and waits that the ownership of the item switch to the client     -> When the ownership switched to the client, the item is added to the client's inventory

That's exactly why it is very tricky to handle. The server is not authorative, and we will need tricks to handle it.