From 75356d1f04f91a3663f4cdbd3ca318136fa6a71a Mon Sep 17 00:00:00 2001 From: Vexatos Date: Sun, 11 Dec 2016 20:04:06 +0100 Subject: [PATCH] Fixed methods ItemInventoryControl not doing what they are supposed to do. --- .../component/traits/ItemInventoryControl.scala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/scala/li/cil/oc/server/component/traits/ItemInventoryControl.scala b/src/main/scala/li/cil/oc/server/component/traits/ItemInventoryControl.scala index 03846a579..f9ff25b2f 100644 --- a/src/main/scala/li/cil/oc/server/component/traits/ItemInventoryControl.scala +++ b/src/main/scala/li/cil/oc/server/component/traits/ItemInventoryControl.scala @@ -17,19 +17,21 @@ trait ItemInventoryControl extends InventoryAware { withItemInventory(args.checkSlot(inventory, 0), itemInventory => result(itemInventory.getSizeInventory)) } - @Callback(doc = "function(inventorySlot:number, slot:number[, count:number=64]):number -- The size of an item inventory in the specified slot.") + @Callback(doc = "function(inventorySlot:number, slot:number[, count:number=64]):number -- Drops an item into the specified slot in the item inventory.") def dropIntoItemInventory(context: Context, args: Arguments): Array[AnyRef] = { withItemInventory(args.checkSlot(inventory, 0), itemInventory => { - val count = args.optItemCount(1) - result(InventoryUtils.extractAnyFromInventory(InventoryUtils.insertIntoInventory(_, itemInventory), inventory, ForgeDirection.UNKNOWN, count)) + val slot = args.checkSlot(itemInventory, 1) + val count = args.optItemCount(2) + result(InventoryUtils.extractAnyFromInventory(InventoryUtils.insertIntoInventorySlot(_, itemInventory, Option(ForgeDirection.UNKNOWN), slot), inventory, ForgeDirection.UNKNOWN, count)) }) } - @Callback(doc = "function(inventorySlot:number, slot:number[, count:number=64]):number -- The size of an item inventory in the specified slot.") + @Callback(doc = "function(inventorySlot:number, slot:number[, count:number=64]):number -- Sucks an item out of the specified slot in the item inventory.") def suckFromItemInventory(context: Context, args: Arguments): Array[AnyRef] = { withItemInventory(args.checkSlot(inventory, 0), itemInventory => { - val count = args.optItemCount(1) - result(InventoryUtils.extractAnyFromInventory(InventoryUtils.insertIntoInventory(_, inventory, slots = Option(insertionSlots)), itemInventory, ForgeDirection.UNKNOWN, count)) + val slot = args.checkSlot(itemInventory, 1) + val count = args.optItemCount(2) + result(InventoryUtils.extractFromInventorySlot(InventoryUtils.insertIntoInventory(_, inventory, slots = Option(insertionSlots)), itemInventory, ForgeDirection.UNKNOWN, slot, count)) }) }