-
-
Save Elix-x/3bdb448ae1d5bbf120d3 to your computer and use it in GitHub Desktop.
Weird bug with ShapedOreRecipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecipeStringTranslator { | |
public static boolean isShaped(String... recipe) { | |
return !ItemStackStringTranslator.isValidItemstackAdvanced(recipe[0]); | |
} | |
public static Object[] fromString(String... srecipe){ | |
Object[] recipe = new Object[srecipe.length]; | |
if(isShaped(srecipe)){ | |
int i; | |
for(i = 0; i < srecipe.length; i++){ | |
if(srecipe[i].length() == 1 && ItemStackStringTranslator.isValidItemstackAdvanced(srecipe[i + 1])) break; | |
} | |
for(int j = 0; j < i; j++){ | |
recipe[j] = srecipe[j]; | |
} | |
for(int j = i; j < srecipe.length; j++){ | |
if(srecipe[j].length() == 1){ | |
recipe[j] = srecipe[j].charAt(0); | |
} else { | |
recipe[j] = ItemStackStringTranslator.fromStringAdvanced(srecipe[j]); | |
} | |
} | |
} else { | |
for(int i = 0; i < srecipe.length; i++){ | |
recipe[i] = ItemStackStringTranslator.fromStringAdvanced(srecipe[i]); | |
} | |
} | |
return recipe; | |
} | |
public static IRecipe fromString(ItemStack result, String... srecipe){ | |
if(isShaped(srecipe)){ | |
return new ShapedOreRecipe(result, fromString(srecipe)); | |
} else { | |
return new ShapelessOreRecipe(result, fromString(srecipe)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment