Skip to content

Commit

Permalink
feat(mc): init 1.21 support
Browse files Browse the repository at this point in the history
Due to Paper ItemStack internal system change, we have wrap SlimefunItemStack. this may cause some problems.
See also: PaperMC/Paper#10852
  • Loading branch information
StarWishsama committed Jul 17, 2024
1 parent 25047d8 commit 2e27d96
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 2e27d96

Please sign in to comment.