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)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/craftdef.cpp

index 286d1eadaf8dc699ec4c492f23b09b284d1ea5f2..210fe9f03d68bb720e7bf40d3b656ff2cb66eb3c 100644 (file)
@@ -923,8 +923,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;*/