From a86bb1e0fc28f166f31b57259c31f9c6ee9bd5c3 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 16 Sep 2016 03:54:35 -1000 Subject: [PATCH] Allow BlockType to be used in `if block` to test for air --- src/mceditlib/blocktypes/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mceditlib/blocktypes/__init__.py b/src/mceditlib/blocktypes/__init__.py index 5c5f543..2de8cd2 100644 --- a/src/mceditlib/blocktypes/__init__.py +++ b/src/mceditlib/blocktypes/__init__.py @@ -90,7 +90,9 @@ class BlockType(namedtuple("_BlockType", "ID meta blocktypeSet")): return self.__dict__[attr] return self.blocktypeSet.getBlockTypeAttr(self, attr) - + + def __nonzero__(self): + return int(self.ID) != 0 # self.ID is a numpy.int id_limit = 4096