use of net.minecraftforge.oredict.ShapelessOreRecipe in project Engine by VoltzEngine-Project.
the class JsonCraftingRecipeData method genRecipes.
@Override
public void genRecipes(List<IRecipe> recipes) {
//If output is a string convert
if (output instanceof String) {
Object out = convertItemEntry((String) output);
if (out != null) {
output = out;
}
}
if (shaped) {
//Shaped starts with a series of strings representing the grid, then goes "char, item, char2, item2...."
boolean convert = false;
int gridEnd = 0;
for (int i = 0; i < data.length; i++) {
Object dataObject = data[i];
//Do not convert until after the first char entry
if (dataObject instanceof Character) {
if (gridEnd == 0) {
gridEnd = i;
}
convert = true;
} else if (convert) {
Object out = convertItemEntry((String) dataObject);
if (out != null) {
data[i] = out;
} else {
Engine.logger().error("The item value of [" + dataObject + "] could not be parsed into a valid recipe item entry. Recipe -> " + this);
return;
}
}
}
//Create recipe
if (output instanceof Block) {
if (largeGrid) {
recipes.add(new RecipeShapedOreLarge((Block) output, data));
} else {
recipes.add(new ShapedOreRecipe((Block) output, data));
}
} else if (output instanceof Item) {
if (largeGrid) {
recipes.add(new RecipeShapedOreLarge((Item) output, data));
} else {
recipes.add(new ShapedOreRecipe((Item) output, data));
}
} else if (output instanceof ItemStack) {
if (largeGrid) {
recipes.add(new RecipeShapedOreLarge((ItemStack) output, data));
} else {
recipes.add(new ShapedOreRecipe((ItemStack) output, data));
}
} else {
Engine.logger().error("The type of output value [" + output + "] could not be recognized for recipe creation. Recipe -> " + this);
}
} else {
//Shapeless is an array of string data
for (int i = 0; i < data.length; i++) {
Object dataObject = data[i];
if (dataObject instanceof String) {
//Convert entries to correct outputs
Object out = convertItemEntry((String) dataObject);
if (out != null) {
data[i] = out;
} else {
Engine.logger().error("The item value of [" + dataObject + "] could not be parsed into a valid recipe item entry. Recipe -> " + this);
return;
}
} else {
Engine.logger().error("The item value of [" + dataObject + "] is not a valid string for parsing. Recipe -> " + this);
return;
}
}
//Create recipe
if (output instanceof Block) {
recipes.add(new ShapelessOreRecipe((Block) output, data));
} else if (output instanceof Item) {
recipes.add(new ShapelessOreRecipe((Item) output, data));
} else if (output instanceof ItemStack) {
recipes.add(new ShapelessOreRecipe((ItemStack) output, data));
} else {
Engine.logger().error("The type of output value [" + output + "] could not be recognized for recipe creation. Recipe -> " + this);
}
}
}
use of net.minecraftforge.oredict.ShapelessOreRecipe in project Engine by VoltzEngine-Project.
the class NuggetRecipeLoader method postInit.
@Override
public void postInit() {
if (DefinedGenItems.NUGGET.item != null) {
EnumSet<GenMaterial> mats = EnumSet.allOf(GenMaterial.class);
mats.remove(GenMaterial.UNKNOWN);
for (GenMaterial material : mats) {
if (OreDictionary.getOres("ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase()), false).size() > 0 && !DefinedGenItems.NUGGET.ignoreMaterials.contains(material)) {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(DefinedGenItems.NUGGET.item, 9, material.ordinal()), "ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase())));
if (DefinedGenItems.INGOT.item != null) {
GameRegistry.addRecipe(new ShapedOreRecipe(DefinedGenItems.INGOT.stack(material), "nnn", "nnn", "nnn", 'n', new ItemStack(DefinedGenItems.NUGGET.item, 1, material.ordinal())));
} else {
GameRegistry.addRecipe(new ShapedOreRecipe(OreDictionary.getOres("ingot" + LanguageUtility.capitalizeFirst(material.name().toLowerCase())).get(0), "nnn", "nnn", "nnn", 'n', new ItemStack(DefinedGenItems.NUGGET.item, 1, material.ordinal())));
}
}
}
}
}
use of net.minecraftforge.oredict.ShapelessOreRecipe in project Railcraft by Railcraft.
the class CraftingPlugin method addShapelessRecipe.
public static void addShapelessRecipe(@Nullable ItemStack result, Object... recipeArray) {
ProcessedRecipe processedRecipe;
try {
processedRecipe = processRecipe(RecipeType.SHAPELESS, result, recipeArray);
} catch (InvalidRecipeException ex) {
Game.logTrace(Level.WARN, ex.getRawMessage());
return;
}
if (processedRecipe.isOreRecipe) {
IRecipe recipe = new ShapelessOreRecipe(processedRecipe.result, processedRecipe.recipeArray);
addRecipe(recipe);
} else
GameRegistry.addShapelessRecipe(processedRecipe.result, processedRecipe.recipeArray);
}
use of net.minecraftforge.oredict.ShapelessOreRecipe in project BetterWithAddons by DaedalusGame.
the class InteractionCondensedOutputs method addUncondensingRecipe.
private void addUncondensingRecipe(ForgeRegistry<IRecipe> registry, String id, ItemStack condensed, ItemStack material) {
ItemStack outmaterial = material.copy();
outmaterial.setCount(8);
ResourceLocation uncompressLoc = new ResourceLocation(Reference.MOD_ID, "uncompress_" + id);
registry.register(new ShapelessOreRecipe(uncompressLoc, outmaterial, condensed).setRegistryName(uncompressLoc));
}
Aggregations