diff --git a/src/net/bdew/lib/items/IStack.scala b/src/net/bdew/lib/items/IStack.scala index 10f2aaf..cefcff1 100644 --- a/src/net/bdew/lib/items/IStack.scala +++ b/src/net/bdew/lib/items/IStack.scala @@ -9,7 +9,8 @@ package net.bdew.lib.items -import net.minecraft.item.{Item, ItemStack} +import net.minecraft.item.{ItemBlock, Item, ItemStack} +import net.minecraft.block.Block /** * Allows matching Items in ItemStacks in scala pattern matches @@ -21,3 +22,14 @@ object IStack { else Some(x.getItem) } + +/** + * Allows matching Blocks in ItemStacks in scala pattern matches + */ +object IStackBlock { + def unapply(x: ItemStack): Option[Block] = + if (x == null || x.getItem == null || !x.getItem.isInstanceOf[ItemBlock]) + None + else + Some(x.getItem.asInstanceOf[ItemBlock].field_150939_a) +}