Skip to content

Commit

Permalink
Merge pull request #2181 from Vexatos/fix-item-inventory-control
Browse files Browse the repository at this point in the history
Fixed methods ItemInventoryControl not doing what they are supposed to do.
  • Loading branch information
fnuecke committed Dec 11, 2016
2 parents 6e1270e + 75356d1 commit a131029
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}

Expand Down

0 comments on commit a131029

Please sign in to comment.