mojira.dev
MC-116618

Dropping items rapidly inside the "Survival Inventory" tab in creative mode deletes items

When you hover over stacks of items in the creative inventory and drop them using either ctrl + q over multiple stacks, or press and hold q over single item stacks, some items will be deleted. This does not occur for survival, or adventure mode.

Steps to Reproduce:

  1. Fill your inventory with stacks of items

  2. Hold down either q or ctrl + q

  3. In quick succession, hover over the item stacks in your inventory

Observed Behavior:

A majority of the items will be deleted.

Expected Result:

None of the items would be deleted, and all would be dropped.

Screenshots/Videos:

[media]

Code Analysis:

(by @unknown)
The reason for this appears to be the ServerGamePacketListenerImpl.dropSpamTickCount. If the threshold is reached the server simply does not not drop an item, however it does not inform the client of that.
(24w18a, Mojang mapping names)

public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket var1) {
      PacketUtils.ensureRunningOnSameThread(var1, this, (ServerLevel)this.player.serverLevel());
      if (this.player.gameMode.isCreative()) {
         boolean var2 = var1.slotNum() < 0;
         ItemStack var3 = var1.itemStack();
         if (!var3.isItemEnabled(this.player.level().enabledFeatures())) {
            return;
         }

         . . .

         boolean var7 = var1.slotNum() >= 1 && var1.slotNum() <= 45;
         boolean var8 = var3.isEmpty() || var3.getCount() <= var3.getMaxStackSize();
         if (var7 && var8) {
            this.player.inventoryMenu.getSlot(var1.slotNum()).setByPlayer(var3);
            this.player.inventoryMenu.broadcastChanges();

         } else if (var2 && var8 && this.dropSpamTickCount < 200) {
            this.dropSpamTickCount += 20;
            this.player.drop(var3, true);
         }
      }

   }

Original Description:

The bug

When you hover over an item in your creative inventory and hold Q to drop those items (fast drop, because you hold Q), some items disappear, but when you are in survival (gamemode 0) zero items get deleted.

Example

Here is an example in video:

[media]

Code analysis

20w09a, Mojang names

The reason for this appears to be the ServerGamePacketListenerImpl.dropSpamTickCount. If the threshold is reached the server simply does not not drop an item, however it does not inform the client.

Linked issues

Attachments

Comments 17

qwerty23495

Can confirm in 1.13-pre5.

Please keep the ticket up to date.

marcono1234

This "fast drop" might not be a feature, see MC-118107.
I can imagine the reason for this bug being the item throw cooldown of Creative mode, but this is only speculation.

tomudding

@marcono1234 In creative when you have a stack of items in your hand (not looking in your inventory) and start throwing them by holding 'Q' no items are deleted (tested this in 1.13 PRE-8). It is just that when you are inside the inventory the items somehow get deleted (by holding 'Q' to throw them).

marcono1234

@@unknown, thanks for pointing that out, I created MC-134399 for that.

By the way, you can create user "mentions" (they are no real mentions but just show the username properly) by writing the username (not "Full name") like this:

[~marcono1234]

See also the Jira help.

tomudding

@@unknown I always have problems with mentions, sometimes they work and sometimes they don't and that time it didn't work, tried it like 4 times with no success (and now it works of course). 

7 more comments
batbrain1998

Can confirm in 1.20.5 pre4.

batbrain1998

Can confirm in 1.20.5.

[Mod] Jingy

I've written a new description to better describe this issue:

When you hover over stacks of items in the creative inventory and drop them using either {{ctrl + q}} over multiple stacks or press and hold {{q}} over single stacks, some items will be deleted. 
This does not occur for survival, or adventure mode.

h3. Steps to Reproduce:
 # (In creative) Fill your inventory with stacks of items
 # Hold down either {{q}} or {{ctrl + q}} 
 # In quick succession, hover over all the items in your inventory

h3. Observed Behavior:
A majority of the items dropped will be deleted.

h3. Expected Result:
None of the items would be deleted, and all would be dropped.

h3. Screenshots/Videos:
 [^Minecraft_116618.mp4] 

h3. Code analysis
The reason for this appears to be the ServerGamePacketListenerImpl.dropSpamTickCount. If the threshold is reached the server simply does not not drop an item, however it does not inform the client.
(24w18a, Mojang mapping names)
{code:java}
   public void handleSetCreativeModeSlot(ServerboundSetCreativeModeSlotPacket var1) {
      PacketUtils.ensureRunningOnSameThread(var1, this, (ServerLevel)this.player.serverLevel());
      if (this.player.gameMode.isCreative()) {
         boolean var2 = var1.slotNum() < 0;
         ItemStack var3 = var1.itemStack();
         if (!var3.isItemEnabled(this.player.level().enabledFeatures())) {
            return;
         }

         CustomData var4 = (CustomData)var3.getOrDefault(DataComponents.BLOCK_ENTITY_DATA, CustomData.EMPTY);
         if (var4.contains("x") && var4.contains("y") && var4.contains("z")) {
            BlockPos var5 = BlockEntity.getPosFromTag(var4.getUnsafe());
            if (this.player.level().isLoaded(var5)) {
               BlockEntity var6 = this.player.level().getBlockEntity(var5);
               if (var6 != null) {
                  var6.saveToItem(var3, this.player.level().registryAccess());
               }
            }
         }

         boolean var7 = var1.slotNum() >= 1 && var1.slotNum() <= 45;
         boolean var8 = var3.isEmpty() || var3.getCount() <= var3.getMaxStackSize();
         if (var7 && var8) {
            this.player.inventoryMenu.getSlot(var1.slotNum()).setByPlayer(var3);
            this.player.inventoryMenu.broadcastChanges();
         } else if (var2 && var8 && this.dropSpamTickCount < 200) {
            this.dropSpamTickCount += 20;
            this.player.drop(var3, true);
         }
      }

   }
{code}
[Mod] Jingy

Considering the original reporter has not touched the issue in three years, I would like to request ownership of it to add the new description I've outlined in my last comment, and also add future affected versions.

tomudding

This appears to have been fixed in 24w38a through MC-276373.

Tom Udding

[Mod] Jingy

(Unassigned)

Confirmed

Gameplay

Normal

Inventory

creative-inventory, drop, drop-item, dropping, inventory, item

Minecraft 1.11.2, Minecraft 17w16b, Minecraft 1.12 Pre-Release 1, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 3, ..., 1.20.5, 1.20.6, 24w19b, 24w21b, 1.21

24w38a

Retrieved