Skip to content

Correctly handle inventory indexing #79

Closed

Description

@caelunshun

I noticed that the handling of the Creative Item packet doesn't take into account the "raw slot" logic:

https://github.com/caelunshun/feather/blob/d3d05d34eefe2047c374a66266e35715ebd9e2b1/server/src/player/inventory.rs#L184-L191

Essentially, packet.slot won't match the "inventory slot" properly. For example, "Creative Slot #0" > is not the hotbar, but the helmet slot. This mapping depends on the "top view" and "bottom view" of the inventory (think of the slots in a crafting bench, vs. the slots in a survival inventory with the equipment).

In Bukkit, there is this concept of "InventoryView" which has a convert-slot function to handle this.

This is an issue because there is a desync as to which item is currently held by the player: using the "hotbar index" for the inventory slot will give the wrong item.

Originally posted by @Momothereal in #46 (comment)

Activity

  1. added
    bug
    on Aug 23, 2019
  2. added this to the 0.4 milestone on Aug 23, 2019
  3. caelunshun commented on Aug 23, 2019

    @caelunshun
    MemberAuthor

    Yes, I see what you mean. Inventory slot indices are currently numbered as per https://wiki.vg/Inventory#Player_Inventory, which is only valid for the normal inventory—not for when e.g. the player is interacting with a crafting table (although those aren't implemented, so I haven't observed the problem).

    I'm not sure of the ideal way to fix this in a Rust-like way. Perhaps we could use an enum type with a variant for each possible slot and then map those variants to raw slot IDs depending on the inventory type.

  4. modified the milestones: 0.4, 0.5 on Aug 27, 2019
  5. modified the milestones: 0.5, 0.6 on Sep 7, 2019
  6. modified the milestones: 0.6, 0.7 on May 4, 2020
  7. added a commit that references this issue on May 18, 2020
    615ded0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty: some

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions