@@ -154,7 +154,7 @@ public static void onReloadClient() {
154154 }
155155 });
156156 stoneItems .forEach (stoneItem -> {
157- try {
157+ try {
158158 GeneratedMaterial generatedMaterial = new GeneratedMaterial (ToolMaterials .STONE , stoneItem .getDefaultStack (), false );
159159 materials .put (generatedMaterial .getKey (), generatedMaterial );
160160 generatedMaterial .copyStatsFrom (materials .get ("stone" ));
@@ -182,8 +182,11 @@ public static void onReloadServer() {
182182 .stream ()
183183 .filter (toolMaterial -> toolMaterial .getRepairIngredient ().getMatchingStacks ().length > 0 )
184184 .filter (toolMaterial -> !toolMaterial .getRepairIngredient ().getMatchingStacks ()[0 ].isIn (RegistryInventory .MIAPI_FORBIDDEN_TAG ))
185- .filter (toolMaterial -> toolMaterial .getRepairIngredient () != null && toolMaterial .getRepairIngredient ().getMatchingStacks () != null )
186- .filter (toolMaterial -> Arrays .stream (toolMaterial .getRepairIngredient ().getMatchingStacks ()).allMatch (itemStack -> MaterialProperty .getMaterialFromIngredient (itemStack ) == null && !itemStack .getItem ().equals (Items .BARRIER )))
185+ .filter (toolMaterial -> toolMaterial .getRepairIngredient () != null &&
186+ toolMaterial .getRepairIngredient ().getMatchingStacks () != null )
187+ .filter (toolMaterial -> Arrays .stream (toolMaterial .getRepairIngredient ().getMatchingStacks ())
188+ .allMatch (itemStack -> MaterialProperty .getMaterialFromIngredient (itemStack ) == null && !itemStack .getItem ().equals (Items .BARRIER )))
189+ .limit (MiapiConfig .OtherConfigGroup .maxGeneratedMaterial .getValue ())
187190 .collect (Collectors .toSet ()).forEach (toolMaterial -> {
188191 if (isValidItem (toolMaterial .getRepairIngredient ().getMatchingStacks ()[0 ].getItem ())) {
189192 GeneratedMaterial generatedMaterial = new GeneratedMaterial (toolMaterial , false );
@@ -199,28 +202,33 @@ public static void onReloadServer() {
199202 }
200203
201204 if (MiapiConfig .OtherConfigGroup .generateWoodMaterials .getValue ()) {
202- Registries .ITEM .stream ().filter (item ->
203- item .getDefaultStack ().isIn (ItemTags .PLANKS ) &&
204- !item .getDefaultStack ().isIn (RegistryInventory .MIAPI_FORBIDDEN_TAG )).forEach (item -> {
205- if (isValidItem (item )) {
206- woodItems .add (item );
207- GeneratedMaterial generatedMaterial = new GeneratedMaterial (ToolMaterials .WOOD , item .getDefaultStack (), false );
208- materials .put (generatedMaterial .getKey (), generatedMaterial );
209- generatedMaterial .copyStatsFrom (materials .get ("wood" ));
210- }
211- });
205+ Registries .ITEM .stream ()
206+ .filter (item -> item .getDefaultStack ().isIn (ItemTags .PLANKS ) &&
207+ !item .getDefaultStack ().isIn (RegistryInventory .MIAPI_FORBIDDEN_TAG ))
208+ .limit (MiapiConfig .OtherConfigGroup .maxGeneratedMaterial .getValue ())
209+ .forEach (item -> {
210+ if (isValidItem (item )) {
211+ woodItems .add (item );
212+ GeneratedMaterial generatedMaterial = new GeneratedMaterial (ToolMaterials .WOOD , item .getDefaultStack (), false );
213+ materials .put (generatedMaterial .getKey (), generatedMaterial );
214+ generatedMaterial .copyStatsFrom (materials .get ("wood" ));
215+ }
216+ });
212217 }
213218
214219 if (MiapiConfig .OtherConfigGroup .generateStoneMaterials .getValue ()) {
215- Registries .ITEM .stream ().filter (item -> item .getDefaultStack ().isIn (ItemTags .STONE_TOOL_MATERIALS ) &&
216- !item .getDefaultStack ().isIn (RegistryInventory .MIAPI_FORBIDDEN_TAG )).forEach (item -> {
217- if (isValidItem (item )) {
218- stoneItems .add (item );
219- GeneratedMaterial generatedMaterial = new GeneratedMaterial (ToolMaterials .STONE , item .getDefaultStack (), false );
220- materials .put (generatedMaterial .getKey (), generatedMaterial );
221- generatedMaterial .copyStatsFrom (materials .get ("stone" ));
222- }
223- });
220+ Registries .ITEM .stream ()
221+ .filter (item -> item .getDefaultStack ().isIn (ItemTags .STONE_TOOL_MATERIALS ) &&
222+ !item .getDefaultStack ().isIn (RegistryInventory .MIAPI_FORBIDDEN_TAG ))
223+ .limit (MiapiConfig .OtherConfigGroup .maxGeneratedMaterial .getValue ())
224+ .forEach (item -> {
225+ if (isValidItem (item )) {
226+ stoneItems .add (item );
227+ GeneratedMaterial generatedMaterial = new GeneratedMaterial (ToolMaterials .STONE , item .getDefaultStack (), false );
228+ materials .put (generatedMaterial .getKey (), generatedMaterial );
229+ generatedMaterial .copyStatsFrom (materials .get ("stone" ));
230+ }
231+ });
224232 }
225233
226234 toolItems .stream ()
@@ -368,7 +376,7 @@ public void addSmithingRecipe(Material sourceMaterial, ItemStack templateItem, S
368376 RecipeManager manager = findManager (isClient );
369377 Collection <Recipe <?>> recipes = manager .values ();
370378 String id = "generated_material_recipe." + key + "." + Registries .ITEM .getId (templateItem .getItem ()) + "." + sourceMaterial .getKey ();
371- id = id .replace (":" ,"." );
379+ id = id .replace (":" , "." );
372380 Identifier recipeId = new Identifier (Miapi .MOD_ID , id );
373381 if (manager .get (recipeId ).isEmpty ()) {
374382 recipes .add (new MaterialSmithingRecipe (
0 commit comments