feather-rs / feather

A Minecraft server implementation in Rust
Apache License 2.0
2.58k stars 143 forks source link

Send entity equipment packet #494

Open Miro-Andrin opened 2 years ago

Miro-Andrin commented 2 years ago

Make it possible to see what items players/mobs have in their main/off-hand

After implementing #492 @Tracreed though about implementing similar feature, but we decided to prioritise working on something else. However if someone is looking for a beginner issue, then this might be something to have a look at. Note however we are uncertain if this should actually be considered a beginner issue, and would probably classify it as beginner++.

Description

Make it so that when mobs or players change their equipment, other clients see the selected item. So if a player/mob equips a sword or some armour it would be visible to others.

To do this one has to send the EntityEquipment packet every time an inventory is changed in a visible way.

To send send a packet to all nearby players, you call the broadcast_nearby_with on the Server struct.

This code should probably be made into a system. And would therefore be put into this folder. Remember to register the system like it is done here.

I am not sure what the best approach is for detecting a visible change in a inventory slot. And to do this well the problem might actually turn into an issue that is less beginner friendly. So a first approximation to the problem, would be to trigger the packet every n'th tick, and add a todo comment.

If you have gotten everything else working and feel like doing something smarter then what I have suggested then I would ask someone on the discord, or on this issue to see if they agree with your approach.