Переглянути джерело

Don't try to craft a non-existent item

Esteban I. RM 6 роки тому
батько
коміт
90e7d42375
1 змінених файлів з 12 додано та 1 видалено
  1. 12 1
      src/craftdef.cpp

+ 12 - 1
src/craftdef.cpp

@@ -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;*/