diff --git a/platform/platform-bukkit/src/main/kotlin/taboolib/platform/util/PlayerUtil.kt b/platform/platform-bukkit/src/main/kotlin/taboolib/platform/util/PlayerUtil.kt index 1eb7dfca7..41464af14 100644 --- a/platform/platform-bukkit/src/main/kotlin/taboolib/platform/util/PlayerUtil.kt +++ b/platform/platform-bukkit/src/main/kotlin/taboolib/platform/util/PlayerUtil.kt @@ -14,7 +14,12 @@ fun HumanEntity.giveItem(itemStack: List) { fun HumanEntity.giveItem(itemStack: ItemStack?, repeat: Int = 1) { if (itemStack.isNotAir()) { - repeat(repeat) { inventory.addItem(itemStack).values.forEach { world.dropItem(location, it) } } + // CraftInventory.addItem 的执行过程中, 实质上有可能修改ItemStack的amount, 如果不注意这一点, 则会吞物品而不自知 + val preAmount = itemStack.amount + repeat(repeat) { + inventory.addItem(itemStack).values.forEach { world.dropItem(location, it) } + itemStack.amount = preAmount + } } } @@ -48,4 +53,4 @@ fun HumanEntity.feed() { fun HumanEntity.saturate() { saturation = 20F -} \ No newline at end of file +}