andrewgazelka / hyperion

170,000 player capable Minecraft game engine built in Rust.
https://andrewgazelka.github.io/hyperion/
Apache License 2.0
472 stars 23 forks source link

Fix issues caused by class selection #613

Open Kumpelinus opened 5 days ago

Kumpelinus commented 5 days ago

If you try to "switch" to the class that you already have (of your current team) it does not give you the kit. Instead it completely clears your inventory.

linear[bot] commented 5 days ago

HYP-97 Fix inventory clear on class selection

Kumpelinus commented 5 days ago

It seems to be just a wrong packet being sent (or not being sent) since other players can see you holding the items while you can't see them yourself.

Kumpelinus commented 5 days ago

I found a few more Issues with this as well.

andrewgazelka commented 4 days ago

I found a few more Issues with this as well.

  • It also resets the xp in the client's xp bar. However it does not reset the xp stat on the server so you will get it back upon gaining xp again (So it is just visual).
  • It removes you from your own tab-list which might indicate further problems (can't confirm that yet).

yea changing the lpayer skin requires "killing and respawning htem" client side which can break al ot of thing... we have to send all the packets including XP packets to make sure their state after respawn is the same as before respawn

Kumpelinus commented 4 days ago

The class selection itself resets your inventory. And the code

.observer::<flecs::OnSet, (
    &Xp,                  //                  (0)
    &UpgradedTo,          //                  (1)
    &Class,               //                  (2)
    &Team,                //                  (3)
    &MainBlockCount,      //                  (4)
    &mut PlayerInventory, //             (5)
)>()

normally observes this and thus gives you the equipment you the equipment.

But since neither your team nor your class changes in the case of selecting the same class + team it does not trigger the apply_inventory method and that leads to your inventory staying empty.

We could either:

I prefer the latter one since you can also add a error message very easily that way.