Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Remove itemstack mutation on player drop method

Open Owen1212055 opened this issue 1 year ago • 2 comments

This appears to cause alot of issues, as the general assumption when calling this method is that the itemstack would not be mutated.

Common issues that this seems to cause is item related actions that later increment a statistic, which is no longer true because the item type changes since its now considered empty. The dupe that this was meant to resolve was patched.

Fixes #11520 Fixes #11765 Supercedes https://github.com/PaperMC/Paper/pull/11521

Owen1212055 avatar Dec 26 '24 22:12 Owen1212055

I have tried to look deeply into all of the changes that may be caused by this and I have seen the following, note that I would like a second opinion from some of these. Note that for analyizing these you must look at the parameter passed and ensure that the itemstack is either cloned or removed from the container properly before being called.

Some interesting calls:

  • ResultSlot.onTake(Player, ItemStack) (net.minecraft.world.inventory) — This looks like where the above bug fix occurs?
  • Inventory.placeItemBackInInventory(ItemStack, boolean) (net.minecraft.world.entity.player) — looked suspicious, altough is fine
  • StonecutterMenu.quickMoveStack(Player, int) (net.minecraft.world.inventory) — This is sus, there is defo mutation in that slot occuring here. Do we cause another bug here?
  • Bucketable.bucketMobPickup(Player, InteractionHand, T) (net.minecraft.world.entity.animal) — behavior change, bucketItemStack will now respect in advancement
  • AbstractContainerMenu#614 -mutation affects outer loop

Owen1212055 avatar Mar 08 '25 05:03 Owen1212055

Also fixes the item drop statistic

Owen1212055 avatar Jun 21 '25 19:06 Owen1212055

Last updated for: 494a797539267ae8418dc42e5feb0a3be33bedfe.

Download the Paperclip jar for this pull request: paper-11831.zip

Maven Publication

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven("https://maven-prs.papermc.io/Paper/pr11831") {
        name = "Maven for PR #11831" // https://github.com/PaperMC/Paper/pull/11831
        mavenContent {
            includeModule("io.papermc.paper", "dev-bundle")
            includeModule("io.papermc.paper", "paper-api")
        }
    }
}

I have same issue with it version server 1.21.7

Hurming avatar Jul 14 '25 15:07 Hurming