Added dependency support for config includes.
parent
90517050b3
commit
4579300e00
|
@ -1,7 +1,10 @@
|
|||
package net.einsteinsci.betterbeginnings.config.json;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -83,6 +86,23 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
|||
for (String json : includedJsons)
|
||||
{
|
||||
JsonAdvancedCraftingHandler handler = BBJsonLoader.deserializeObject(json, JsonAdvancedCraftingHandler.class);
|
||||
|
||||
boolean missingDependencies = false;
|
||||
for (String mod : handler.getModDependencies())
|
||||
{
|
||||
if (!Loader.isModLoaded(mod))
|
||||
{
|
||||
LogUtil.log(Level.WARN, "Mod '" + mod + "' missing, skipping all recipes in file.");
|
||||
missingDependencies = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDependencies)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
includes.add(handler);
|
||||
|
||||
for (JsonAdvancedRecipe r : handler.getRecipes())
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package net.einsteinsci.betterbeginnings.config.json;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -87,6 +90,23 @@ public class BrickOvenConfig implements IJsonConfig
|
|||
for (String json : includedJsons)
|
||||
{
|
||||
JsonBrickOvenRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonBrickOvenRecipeHandler.class);
|
||||
|
||||
boolean missingDependencies = false;
|
||||
for (String mod : handler.getModDependencies())
|
||||
{
|
||||
if (!Loader.isModLoaded(mod))
|
||||
{
|
||||
LogUtil.log(Level.WARN, "Mod '" + mod + "' missing, skipping all recipes in file.");
|
||||
missingDependencies = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDependencies)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
includes.add(handler);
|
||||
|
||||
for (JsonBrickOvenShapedRecipe r : handler.getShaped())
|
||||
|
|
|
@ -10,15 +10,13 @@ import java.util.List;
|
|||
|
||||
public class JsonAdvancedCraftingHandler
|
||||
{
|
||||
private List<JsonAdvancedRecipe> recipes;
|
||||
private List<JsonAdvancedRecipe> recipes = new ArrayList<>();
|
||||
|
||||
private List<String> includes;
|
||||
private List<String> includes = new ArrayList<>();
|
||||
private List<String> modDependencies = new ArrayList<>();
|
||||
|
||||
public JsonAdvancedCraftingHandler()
|
||||
{
|
||||
recipes = new ArrayList<>();
|
||||
includes = new ArrayList<>();
|
||||
|
||||
// TESTING ONLY
|
||||
recipes.add(new JsonAdvancedRecipe(new ItemStack(Items.string, 38),
|
||||
new Object[]{new ItemStack(RegisterItems.cloth, 7), "dustRedstone", 13}, "ox ", "xxx", " xo",
|
||||
|
@ -34,4 +32,9 @@ public class JsonAdvancedCraftingHandler
|
|||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public List<String> getModDependencies()
|
||||
{
|
||||
return modDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,19 +9,16 @@ import java.util.List;
|
|||
|
||||
public class JsonBrickOvenRecipeHandler
|
||||
{
|
||||
private List<JsonBrickOvenShapedRecipe> shaped;
|
||||
private List<JsonBrickOvenShapelessRecipe> shapeless;
|
||||
private List<JsonBrickOvenShapedRecipe> shaped = new ArrayList<>();
|
||||
private List<JsonBrickOvenShapelessRecipe> shapeless = new ArrayList<>();
|
||||
|
||||
private List<String> includes;
|
||||
private List<String> includes = new ArrayList<>();
|
||||
private List<String> modDependencies = new ArrayList<>();
|
||||
|
||||
private List<String> __COMMENTS;
|
||||
private List<String> __COMMENTS = new ArrayList<>();
|
||||
|
||||
public JsonBrickOvenRecipeHandler()
|
||||
{
|
||||
shaped = new ArrayList<>();
|
||||
shapeless = new ArrayList<>();
|
||||
includes = new ArrayList<>();
|
||||
|
||||
__COMMENTS = new ArrayList<>();
|
||||
__COMMENTS.add("Brick Oven recipes do not support ore dictionary in ingredients.");
|
||||
__COMMENTS.add("This will change eventually. This only applies to Brick Oven recipes.");
|
||||
|
@ -47,4 +44,9 @@ public class JsonBrickOvenRecipeHandler
|
|||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public List<String> getModDependencies()
|
||||
{
|
||||
return modDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,13 @@ import java.util.List;
|
|||
|
||||
public class JsonKilnRecipeHandler
|
||||
{
|
||||
private List<JsonKilnRecipe> recipes;
|
||||
private List<String> includes;
|
||||
private List<JsonKilnRecipe> recipes = new ArrayList<>();
|
||||
|
||||
private List<String> includes = new ArrayList<>();
|
||||
private List<String> modDependencies = new ArrayList<>();
|
||||
|
||||
public JsonKilnRecipeHandler()
|
||||
{
|
||||
recipes = new ArrayList<>();
|
||||
includes = new ArrayList<>();
|
||||
|
||||
// TESTING ONLY
|
||||
recipes.add(new JsonKilnRecipe(new ItemStack(Blocks.bedrock), new ItemStack(Items.blaze_rod), 0.5f));
|
||||
}
|
||||
|
@ -30,4 +29,9 @@ public class JsonKilnRecipeHandler
|
|||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public List<String> getModDependencies()
|
||||
{
|
||||
return modDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,13 @@ import java.util.List;
|
|||
|
||||
public class JsonSmelterRecipeHandler
|
||||
{
|
||||
private List<JsonSmelterRecipe> recipes;
|
||||
private List<JsonSmelterRecipe> recipes = new ArrayList<>();
|
||||
|
||||
private List<String> includes;
|
||||
private List<String> includes = new ArrayList<>();
|
||||
private List<String> modDependencies = new ArrayList<>();
|
||||
|
||||
public JsonSmelterRecipeHandler()
|
||||
{
|
||||
recipes = new ArrayList<>();
|
||||
includes = new ArrayList<>();
|
||||
|
||||
// TESTING ONLY //
|
||||
recipes.add(new JsonSmelterRecipe(new ItemStack(Blocks.bedrock), new ItemStack(Items.golden_hoe), 0.5f, 1, 0));
|
||||
}
|
||||
|
@ -31,4 +29,9 @@ public class JsonSmelterRecipeHandler
|
|||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public List<String> getModDependencies()
|
||||
{
|
||||
return modDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package net.einsteinsci.betterbeginnings.config.json;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -83,6 +86,23 @@ public class KilnConfig implements IJsonConfig
|
|||
for (String json : includedJsons)
|
||||
{
|
||||
JsonKilnRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonKilnRecipeHandler.class);
|
||||
|
||||
boolean missingDependencies = false;
|
||||
for (String mod : handler.getModDependencies())
|
||||
{
|
||||
if (!Loader.isModLoaded(mod))
|
||||
{
|
||||
LogUtil.log(Level.WARN, "Mod '" + mod + "' missing, skipping all recipes in file.");
|
||||
missingDependencies = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDependencies)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
includes.add(handler);
|
||||
|
||||
for (JsonKilnRecipe r : handler.getRecipes())
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package net.einsteinsci.betterbeginnings.config.json;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -82,6 +85,23 @@ public class SmelterConfig implements IJsonConfig
|
|||
for (String json : includedJsons)
|
||||
{
|
||||
JsonSmelterRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonSmelterRecipeHandler.class);
|
||||
|
||||
boolean missingDependencies = false;
|
||||
for (String mod : handler.getModDependencies())
|
||||
{
|
||||
if (!Loader.isModLoaded(mod))
|
||||
{
|
||||
LogUtil.log(Level.WARN, "Mod '" + mod + "' missing, skipping all recipes in file.");
|
||||
missingDependencies = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (missingDependencies)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
includes.add(handler);
|
||||
|
||||
for (JsonSmelterRecipe r : handler.getRecipes())
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.blocks.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
Loading…
Reference in New Issue