Don't remove furnace if something is inside it.
authorJacobF <queatz@gmail.com>
Wed, 24 Aug 2011 22:53:06 +0000 (18:53 -0400)
committerJacobF <queatz@gmail.com>
Wed, 24 Aug 2011 22:53:06 +0000 (18:53 -0400)
src/content_nodemeta.cpp
src/content_nodemeta.h

index 433e6d04b23e372138eaee5f33d945fd295d00b9..f3d0e0fdc84cc73739b1e5a0bd636b1fd0b96281 100644 (file)
@@ -195,6 +195,24 @@ std::string FurnaceNodeMetadata::infoText()
                return s;
        }
 }
+bool FurnaceNodeMetadata::nodeRemovalDisabled()
+{
+       /*
+               Disable removal if furnace is not empty
+       */
+       InventoryList *list[3] = {m_inventory->getList("src"),
+       m_inventory->getList("dst"), m_inventory->getList("fuel")};
+       
+       for(int i = 0; i < 3; i++) {
+               if(list[i] == NULL)
+                       continue;
+               if(list[i]->getUsedSlots() == 0)
+                       continue;
+               return true;
+       }
+       return false;
+       
+}
 void FurnaceNodeMetadata::inventoryModified()
 {
        dstream<<"Furnace inventory modification callback"<<std::endl;
index 84c3aed9d030ae76a9989d64c0706ccbc6b51bc7..50decd91081782242808797e4fb42041bbc37e66 100644 (file)
@@ -76,6 +76,7 @@ public:
        virtual Inventory* getInventory() {return m_inventory;}
        virtual void inventoryModified();
        virtual bool step(float dtime);
+       virtual bool nodeRemovalDisabled();
        virtual std::string getInventoryDrawSpecString();
 
 private: