mojira.dev
MC-29318

Client misses inventory updates while player is manipulating items - causes invisible items

The bug

When using whatever container that automatically updates the contents of a slot (like a furnace) and if the player, with the container GUI open, is constantly moving items into the inventory, the player won't see the container slot update (like a raw steak being cooked).

How to reproduce

  1. Open the furnace gui

  2. Place charcoal/coal and keep some item in your inventory

  3. Place something to be cooked into the furnace

  4. When the progress bar is almost at the end, start continuously left clicking an item in the inventory

What should happen is that the item to be cooked doesn't update (if it doesn't happen the first time, just retry), the progress bar has finished, and you won't have any item in the output slot, but if you click in it you will get the item cooked.

This also occurs with the /replaceitem command:

How to reproduce

  1. Put a command block on a clock, with a command such as:

    /replaceitem entity @p inventory.0 golden_apple

    → This will put a golden apple in the first slot of your inventory

  2. Open your inventory, and move the golden apple to another slot

  3. As soon as a new one appears, grab it and move it to another slot as well
    → If you got the timing right, the slot will appear blank, even though the command block output in the chat window continues to say "[@: Replaced slot 9 with 1 x [Golden Apple]]"

  4. Turn off the clock

  5. Exit the world

  6. Re-enter the world, and open your inventory
    → There will be a golden apple in the first slot

Why this happens:

This happen because there's a boolean in EntityPlayerMP that's set to true when the server receives a window click packet and then there the function that should send the slot updates is called, though if this boolean is true it will not send the packet to the client to update it (while the server-side thinks from the next update on that the client has received the update).
Basically if the server code updates the content of some slots in the container (raw food to be removed, output slot set to cooked food) while the player is moving other items in the inventory.. it won't get the update.

So one way to fix this would be to know which slot is getting modified by player and block the updates only for that slot and not all the container slots. Another way would be having a resend list where clients that didn't got a certain slot update, get a resend of the packet from the server.

Linked issues

Attachments

Comments 21

kumasasa

Confirmed.

Ezekiel

Is this still a concern in the latest Minecraft version 14w30c? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Stefano Bonicatti

I've updated the affected version because the problem is still present in 14w30c, the bug is reproducible in the same way.

galaxy_2alex

Is this still a concern in the current Minecraft version 1.8.1 Prerelease 3 / Launcher version 1.5.3 or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Stefano Bonicatti

Well i have to say that it still happens but in a corner case.
Basicly if the output slot is empty, it all works.
Though if there's already an item and another is in the way and if 2 seconds before that item arrives (cooks if its a furnace) you start moving quickly stuff in the inventory, you won't see the stack number updating, so it seems there's only one item. And you can do this for every new item, so that maybe you finally click on the output and receive 10 items.
Now, i don't know if it's worth updating the affected version, i mean.. this is a very corner case ^^.

11 more comments
Saverio

it appears a lot in snapshots 1.15 but also in some versions 1.14

Iosiv Visokogorskiy

This bug still present in 1.16.1?

user-f2760

Yes, still the case; Put this in a repeating command block:

replaceitem entity @p hotbar.8 stone

and pick up the item a couple of times, at one point, the client will no longer see an item, but an item is in fact there.

user-f2760

Still in 1.16.3.

Nanogamer7

I could recreate a similar bug in 1.17.1 with a function on tick

execute as @a[team=blue,nbt=!{Inventory:[{id:"minecraft:tnt"}]}] if score Aqua tnt matches 1.. if score match match matches 2 run function tntbattle:tnt-blue
give @s minecraft:tnt 1
scoreboard players remove Aqua tnt 1

Stefano Bonicatti

boq

Confirmed

Important

Networking

inventory, invisible, item, replaceitem, slot

Minecraft 1.6.2, Minecraft 14w30c, Minecraft 1.8.1, Minecraft 1.8.2-pre6, Minecraft 15w44b, ..., 20w30a, 1.16.2, 1.16.3, 20w46a, 20w51a

21w10a

Retrieved