mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-11 15:57:41 +00:00
Added ItemUtils.findItemInInventory
This commit is contained in:
1 parent
8891cfff06
commit
4697c96cf2
1 file changed
+6
-1
@@ -10,7 +10,7 @@
|
||||
package net.bdew.lib.items
|
||||
|
||||
import net.minecraft.entity.item.EntityItem
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.inventory.IInventory
|
||||
@@ -76,4 +76,9 @@ object ItemUtils {
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
def findItemInInventory(inv: IInventory, item: Item) =
|
||||
Range(0, inv.getSizeInventory).map(x => x -> inv.getStackInSlot(x))
|
||||
.find({ case (slot, stack) => stack != null && stack.getItem == item })
|
||||
.map({ case (slot, stack) => slot })
|
||||
}
|
||||
Reference in new issue
Block a user