Closed daisukiKaffuChino closed 3 months ago
在 onInventoryChange 的回调方法中,使用 player.clearItem() 方法始终返回0,无法正确清除指定物品。 在 onServerStarted 等其他事件的回调中则正常。
mc.listen("onInventoryChange", function(player, slotNum, oldItem, newItem) count = player:clearItem(newItem.type, 64) logger.info(count) end)
正确返回不为0的数量
No response
Windows 11
1.12.81
0.12.3
0.7.12
onInventoryChange被触发时,newItem还没有被添加到玩家的背包中,所以不可能通过clearItem进行清除 建议使用setTimeout对clearItem操作进行延后
Describe the bug
在 onInventoryChange 的回调方法中,使用 player.clearItem() 方法始终返回0,无法正确清除指定物品。 在 onServerStarted 等其他事件的回调中则正常。
To Reproduce
Expected behavior
正确返回不为0的数量
Screenshots
No response
Platform
Windows 11
BDS Version
1.12.81
LeviLamina Version
0.12.3
LegacyScriptEngine Version
0.7.12
Additional context
No response