Roundaround / mc-fabric-pickup-notifications

MIT License
4 stars 0 forks source link

Why required on the server? #16

Closed Madis0 closed 2 years ago

Madis0 commented 2 years ago

I'm just curious, what technical limits made it be required on the server since 1.1.0.

Roundaround commented 2 years ago

Unfortunately there's no consistent way to determine when an item is added to the inventory - it's a concept that simply doesn't exist in vanilla code. The closest thing we have is an event that tells the client to animate an item on the ground as it is picked up by an entity, but there are some issues with it (doesn't always trigger, the amount is sometimes incorrect for large amounts of items, etc.). We can't check the inventory directly in the client side either because the inventory instance is kept only on the server and simply rendered on screen based on what menu you have open (so with no menu open, all the client actually knows about is the hotbar). In order to provide the best possible experience and not just feel like it was thrown haphazardly together, I decided it was best to add my own logic on the server side to constantly check the inventory for changes and alert the client whenever items are added, which is then shown on screen as the pickup notification.

Long-winded explanation but hopefully that clears things up!