Mojira Archive
MC-271123

When copying items with the middle mouse button, the components are only lightly copied.

While creating a Mod, I discovered that when using the ItemStack.copy() method to duplicate items, the stacking components of the items actually undergo a shallow copy, which may lead to potential issues.

Here are the steps to replicate the issue:

  1. Launch the game in debug mode using IDEA and switch to creative mode.
  2. Obtain a Shulker Box containing items.
  3. Open a GUI (not the player's inventory).
  4. Use the mouse middle button to duplicate the item.
  5. Set a breakpoint in the program and inspect the player's open inventory.
  6. You will notice that the components of the items in the container have the same address values.

Note: Please do not replicate this issue in the player's inventory GUI. Instead, replicate it in the GUI of a chest container.

 

在制作Mod时,我发现使用ItemStack.copy()方法复制物品时,物品的堆叠组件实际上进行的是浅拷贝,这可能会带来一些潜在的问题。

1.用IDEA的debug启动游戏并切换到创造模式

2.拿一个装有物品的潜影盒

3.打开一个GUI(不要打开玩家的物品栏)

4.使用鼠标中键复制物品

5.在程序中打一个断点,然后查看玩家打开的物品栏

6.可以看到容器中物品的组件有相同的地址值

注:不要在玩家的物品栏GUI里复刻该问题,应该在一个箱子容器的GUI中复刻

Invalid

qwerty

2024-04-25, 03:18 AM

2024-04-25, 06:38 PM

2024-04-25, 06:38 PM

0

2

Unconfirmed

(Unassigned)

1.20.5

-