fix: добавлена проверка на размер паттерна верстака

This commit is contained in:
Reider745
2024-03-25 18:37:46 +03:00
parent e4405166a9
commit fffd1e5c1c
2 changed files with 12 additions and 2 deletions
@@ -59,6 +59,7 @@ public class InnerCoreServer {
} }
public static final int PROTOCOL = 422; public static final int PROTOCOL = 422;
public static final int RECIPES_PROTOCOL = 419;
public static final int EXIT_CODE_NO_INTERNAL_PACKAGE = 32; public static final int EXIT_CODE_NO_INTERNAL_PACKAGE = 32;
public static final int EXIT_CODE_NO_MODPACK = 33; public static final int EXIT_CODE_NO_MODPACK = 33;
@@ -130,8 +130,17 @@ public class NativeWorkbench {
} }
ingredients.put(ingredient.getKey(), item); ingredients.put(ingredient.getKey(), item);
} }
for(int i = 0;i < recipe.pattern.length;i++){
if(recipe.pattern[i].length() > 3) {
Logger.warning("NativeWorkbench", "Skip recipe, error pattern: "+Arrays.toString(recipe.pattern) +", item: "+result);
accepted = false;
break;
}
}
if (accepted) { if (accepted) {
craftingManager.registerRecipe(419, craftingManager.registerRecipe(InnerCoreServer.RECIPES_PROTOCOL,
new ShapedRecipe(result, recipe.pattern, ingredients, new ArrayList<>())); new ShapedRecipe(result, recipe.pattern, ingredients, new ArrayList<>()));
} }
} else { } else {
@@ -151,7 +160,7 @@ public class NativeWorkbench {
ingredients.add(item); ingredients.add(item);
} }
if (accepted) { if (accepted) {
craftingManager.registerRecipe(419, new ShapelessRecipe(result, ingredients)); craftingManager.registerRecipe(InnerCoreServer.RECIPES_PROTOCOL, new ShapelessRecipe(result, ingredients));
} }
} }
} }