Fixed bug causing some rewards to disappear instead of dropping when inventory fills up as a result of receiving the reward

This commit is contained in:
Avi Weinstock 2023-09-19 13:30:37 +00:00 committed by Ryan
parent 5baa876a55
commit f4163e733a

View file

@ -368,7 +368,14 @@ fun replaceSlot(player: Player, slot: Int, item: Item, currentItem: Item? = null
*/
fun addItemOrDrop(player: Player, id: Int, amount: Int = 1) {
val item = Item(id, amount)
if (!player.inventory.add(item)) GroundItemManager.create(item, player)
if(amount == 1 || item.definition.isStackable) {
if (!player.inventory.add(item)) GroundItemManager.create(item, player)
} else {
val singleItem = Item(id, 1)
for(i in 0 until amount) {
if(!player.inventory.add(singleItem)) GroundItemManager.create(singleItem, player)
}
}
}
/**