From 8891cfff069eb73cde41dd2505201022d1b312c4 Mon Sep 17 00:00:00 2001 From: bdew Date: Wed, 19 Mar 2014 11:28:34 +0200 Subject: [PATCH] Added extractor (for scala pattern matching) for ItemStack --- src/net/bdew/lib/items/IStack.scala | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/net/bdew/lib/items/IStack.scala diff --git a/src/net/bdew/lib/items/IStack.scala b/src/net/bdew/lib/items/IStack.scala new file mode 100644 index 0000000..10f2aaf --- /dev/null +++ b/src/net/bdew/lib/items/IStack.scala @@ -0,0 +1,23 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/bdlib + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt + */ + +package net.bdew.lib.items + +import net.minecraft.item.{Item, ItemStack} + +/** + * Allows matching Items in ItemStacks in scala pattern matches + */ +object IStack { + def unapply(x: ItemStack): Option[Item] = + if (x == null || x.getItem == null) + None + else + Some(x.getItem) +}