-
-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add entity equipment support #254
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start. Mostly minor nitpicks.
Co-authored-by: Carson McManus <[email protected]>
@dyc3 Thank you for the review! I've made some changes based on your recomendations |
Just quickly chiming in, I think the packet you're looking for to set the player's inventory is This is sent on first connect to initialize the player inventory, and I think |
@mymatsubara are you still working on this PR? |
@LeoDog896 I stopped working on it. Feel free to close it |
👍 I'll fork your valence fork to continue this PR. |
@LeoDog896 Thank you very much! If you got any question about the code, feel free to ask me. |
# Objective - make valence work with entity equipment (armor, main/off hand items) # Solution adds the crate `valence_equipment` that exposes the Equipment Plugin. every `LivingEntity` will have a `Equipment` Component. The Equipment plugin will NOT be compatible with the inventory by default (thats intended, as that makes it possible to use the equipment feature without the inventory feature + I do think there are probably use cases where you want to make players appear as having armor, although they dont have it in their inventory) This PR would add Events when entities are (un)loaded by a player (used for sending equipment once the player loads an entity). I do believe this might also be a useful feature outside of the equipment feature. used #254 as reference + stole example idea fixes #662 Opening as a draft for now (might refactor the updating/event emitting system). Let me know what you think of the Entity Load/Unload events.
Description
Main additions:
Component
calledEquipment
which tracks entity's current equipment and if they have been modified.update_equipment
which sendsSetEquipment
packets to all clients in view, when an entity with aEquipment
component is modified.McEntity::write_init_packets
to also sendSetEquipment
packets.random_equipment.rs
exampleThese change only have cosmetic effect for now, but the
Equipment
component can be also used when dealing with game logic when equipment data is required.Test Plan
Steps:
cargo test -p valence --tests
(there is a unit test inequipment.rs
)random_equipment
example with:cargo run --example random_equipment
localhost
McEntity
will be assigned a random set of equipment every secondVideo of the
random_equipment
exampleMinecraft.1.19.3.-.Multiplayer.3rd-party.Server.2023-02-20.18-26-53.mp4
PROBLEM: As we can see from the video, our client only display equipment changes from other players, but not from our own player entity. This happens because the equipment of our player entity are tracked client-side, thus the
SetEquipment
packet does have effect when theentity_id
is equal to your player entity id. There might me another packet type which can be used for such case, but I'm not sure don't know which one 😞Related
Issue related: #223