Skip to content

Setting armor with an open window causes desync #122

Description

@lolo45654

Setting a player's armor while an InvUI window is open causes the client and server to become desynchronized. The armor does not appear to be equipped until the inventory is explicitly re-synchronized.

Steps to reproduce:

Window.builder()
        .addOpenHandler(() -> player.getInventory().setChestplate(ItemStack.of(Material.DIAMOND_CHESTPLATE)))
        .open(player);
  1. Ensure your inventory is empty.
  2. Run the code snippet above.
  3. Close the opened inventory.
  4. Observe how you are not visually wearing the diamond chestplate.
  5. Click the chestplate armor slot. The diamond chestplate will appear on your cursor.

Video:

invui-armor-desync.mp4

Expected Behavior:
The diamond chestplate should be visible in step 4. Ideally, it should already be visible after step 2 for clients using mods that display armor independently of the inventory (e.g. uku's Armor HUD).

Possible cause:
This appears to be caused by container_set_slot and container_set_content packets being completely discarded, while updates to armor slots are not reproduced.

pl.discard(player, ClientboundContainerSetContentPacket.class);
pl.discard(player, ClientboundContainerSetDataPacket.class);
pl.discard(player, ClientboundContainerSetSlotPacket.class);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions