Don't try to craft a non-existent item
authorEsteban I. RM <me@exio4.xyz>
Sun, 15 Oct 2017 05:52:05 +0000 (02:52 -0300)
committersfan5 <sfan5@live.de>
Mon, 16 Oct 2017 08:13:45 +0000 (10:13 +0200)
src/craftdef.cpp

index 8aa8099306bec44b268b833367851bdacdc91bc7..922ea345ee5b73c92560e42f110c9c65aa743954 100644 (file)
@@ -907,8 +907,19 @@ public:
                                        << " against " << def->dump() << std::endl;*/
 
                                if (def->check(input, gamedef)) {
+                                       // Check if the crafted node/item exists
+                                       CraftOutput out = def->getOutput(input, gamedef);
+                                       ItemStack is;
+                                       is.deSerialize(out.item, gamedef->idef());
+                                       if (!is.isKnown(gamedef->idef())) {
+                                               infostream << "trying to craft non-existent "
+                                                       << out.item << ", ignoring recipe" << std::endl;
+                                               continue;
+                                       }
+
                                        // Get output, then decrement input (if requested)
-                                       output = def->getOutput(input, gamedef);
+                                       output = out;
+                    
                                        if (decrementInput)
                                                def->decrementInput(input, output_replacement, gamedef);
                                        /*errorstream << "Check RETURNS TRUE" << std::endl;*/