DEADSOFTWARE

Add crafting
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / mouse / SelectCreativeInventoryItemMouseInputHandler.kt
index e6fb732c2fb118e83ab118a548e76edcf7b8c50e..7c587b67b7162415ecceeb9525ce568fcdb2831c 100644 (file)
@@ -45,16 +45,14 @@ class SelectCreativeInventoryItemMouseInputHandler @Inject constructor(
 
         val itemIndex = (gameWindowsManager.creativeScrollAmount * GameWindowsConfigs.Creative.itemsInRow +
                 (xOnGrid.toInt() + yOnGrid.toInt() * GameWindowsConfigs.Creative.itemsInRow))
-
-        mobsController.player.inventory.copyInto(
-            destination = mobsController.player.inventory,
-            destinationOffset = 1,
-            startIndex = 0,
-            endIndex = mobsController.player.inventory.size - 1
-        )
-
         val item = gameItemsHolder.getItemFromCreativeInventory(itemIndex)
-        mobsController.player.inventory[0] = item.toInventoryItem(amount = item.params.maxStack)
+        mobsController.player.inventory.reverse()
+        mobsController.player.inventory.add(item.toInventoryItem(amount = item.params.maxStack))
+        mobsController.player.inventory.reverse()
+
+        if (mobsController.player.inventory.size > 36) {
+            mobsController.player.inventory.dropLast(mobsController.player.inventory.size - 36)
+        }
     }
 
 }
\ No newline at end of file