mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-12 16:27:51 +00:00
added IStackBlock for pattern matching with ItemBlocks
This commit is contained in:
1 parent
a10e90a1e1
commit
d67bd24eda
1 file changed
+13
-1
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user