Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Jul 17, 2024
2 parents be9a3e5 + 2e27d96 commit d36ce9d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,17 @@ public ChestMenu addPlayerInventoryClickHandler(MenuClickHandler handler) {
* @return The ChestMenu Instance
*/
public ChestMenu addItem(int slot, ItemStack item) {
// do shallow copy due to Paper ItemStack system change
// See also: https://github.com/PaperMC/Paper/pull/10852
ItemStack clone = item == null ? null : new ItemStack(item.getType(), item.getAmount());

if (clone != null && item.hasItemMeta()) {
clone.setItemMeta(item.getItemMeta());
}

setSize((int) (Math.max(getSize(), Math.ceil((slot + 1) / 9d) * 9)));
this.items.set(slot, item);
this.inventory.setItem(slot, item);
this.items.set(slot, clone);
this.inventory.setItem(slot, clone);
return this;
}

Expand Down

0 comments on commit d36ce9d

Please sign in to comment.