Update to support updated recipe format in reborn core.
(cherry picked from commit 6aa8fde64a
)
# Conflicts:
# src/main/java/techreborn/api/recipe/BaseRecipe.java
# src/main/java/techreborn/api/recipe/recipeConfig/RecipeConfigManager.java
# src/main/java/techreborn/compat/jei/BaseRecipeWrapper.java
# src/main/java/techreborn/compat/minetweaker/MTGeneric.java
# src/main/java/techreborn/tiles/TileAlloyFurnace.java
This commit is contained in:
parent
ebb7578391
commit
5588bda10b
1 changed files with 0 additions and 63 deletions
|
@ -1,63 +0,0 @@
|
|||
package techreborn.api.recipe.recipeConfig;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RecipeConfigManager {
|
||||
|
||||
public static ArrayList<RecipeConfig> configs = new ArrayList<>();
|
||||
|
||||
static File configFile = null;
|
||||
|
||||
public static void load(File configDir) {
|
||||
if (configFile == null) {
|
||||
configFile = new File(configDir, "techRebornRecipes.json");
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
if (configFile.exists()) {
|
||||
configFile.delete();
|
||||
}
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(configs);
|
||||
try {
|
||||
FileWriter writer = new FileWriter(configFile);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canLoadRecipe(IBaseRecipeType recipeType) {
|
||||
RecipeConfig config = new RecipeConfig();
|
||||
for (ItemStack stack : recipeType.getInputs()) {
|
||||
config.addInputs(itemToConfig(stack));
|
||||
}
|
||||
for (ItemStack stack : recipeType.getOutputs()) {
|
||||
config.addOutputs(itemToConfig(stack));
|
||||
}
|
||||
config.enabled = true;
|
||||
config.setMachine(recipeType.getRecipeName());
|
||||
configs.add(config);
|
||||
return config.enabled;
|
||||
}
|
||||
|
||||
public static ConfigItem itemToConfig(ItemStack stack) {
|
||||
ConfigItem newItem = new ConfigItem();
|
||||
newItem.setItemName(stack.getItem().getUnlocalizedName());
|
||||
newItem.setMeta(stack.getItemDamage());
|
||||
newItem.setStackSize(stack.stackSize);
|
||||
newItem.setLocalName(stack.getDisplayName());
|
||||
return newItem;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue