Moved advanced crafting recipes to be 100% on config.
parent
51ce6f9691
commit
48fd361636
|
@ -150,7 +150,8 @@ public class BBConfig
|
||||||
|
|
||||||
// Crafting
|
// Crafting
|
||||||
advancedCraftingForLotsOfThings = config.getBoolean("Advanced crafting for lots of things", CRAFTING, true,
|
advancedCraftingForLotsOfThings = config.getBoolean("Advanced crafting for lots of things", CRAFTING, true,
|
||||||
"Require Advanced Crafting for things like doors, pistons, chests, etc.");
|
"Require Advanced Crafting for things like doors, pistons, chests, etc." +
|
||||||
|
" Delete your config/betterbeginnings/advancedcrafting/main.json file afterward.");
|
||||||
removeCraftedFoodRecipes = config.getBoolean("Remove crafted food recipes", CRAFTING, true,
|
removeCraftedFoodRecipes = config.getBoolean("Remove crafted food recipes", CRAFTING, true,
|
||||||
"Remove crafting recipes of vanilla food items, enforcing the use of the brick ovens.");
|
"Remove crafting recipes of vanilla food items, enforcing the use of the brick ovens.");
|
||||||
canMakeChainArmor = config.getBoolean("Enable chain armor", CRAFTING, true,
|
canMakeChainArmor = config.getBoolean("Enable chain armor", CRAFTING, true,
|
||||||
|
@ -158,15 +159,19 @@ public class BBConfig
|
||||||
removeWoodToolRecipes = config.getBoolean("Remove wooden tool recipes", CRAFTING, true,
|
removeWoodToolRecipes = config.getBoolean("Remove wooden tool recipes", CRAFTING, true,
|
||||||
"Remove recipes for wooden pickaxe, axe, shovel, and hoe.");
|
"Remove recipes for wooden pickaxe, axe, shovel, and hoe.");
|
||||||
anyStringForTraps = config.getBoolean("Any string for traps", CRAFTING, false,
|
anyStringForTraps = config.getBoolean("Any string for traps", CRAFTING, false,
|
||||||
"Allow any string to be used for tripwire hooks, trapped chests, etc.");
|
"Allow any string to be used for tripwire hooks, trapped chests, etc. Delete your" +
|
||||||
|
" config/betterbeginnings/advancedcrafting/main.json file afterward.");
|
||||||
allowStringAsToolBinding = config.getBoolean("Allow string and twine as tool binding", CRAFTING, true,
|
allowStringAsToolBinding = config.getBoolean("Allow string and twine as tool binding", CRAFTING, true,
|
||||||
"Allow string and twine to be used in place of leather strips in tool bindings, at a higher cost.");
|
"Allow string and twine to be used in place of leather strips in tool bindings, at a higher cost." +
|
||||||
|
" Delete your config/betterbeginnings/advancedcrafting/main.json file afterward.");
|
||||||
requireBlazePowderForDiamondPick = config.getBoolean("Require blaze powder for diamond pick", CRAFTING, true,
|
requireBlazePowderForDiamondPick = config.getBoolean("Require blaze powder for diamond pick", CRAFTING, true,
|
||||||
"Require blaze powder for a Diamond Pickaxe like all other diamond tools. This will require a trip to the" +
|
"Require blaze powder for a Diamond Pickaxe like all other diamond tools. This will require a trip to the" +
|
||||||
" Nether unless 'Netherless blaze powder recipe' is set to true.");
|
" Nether unless 'Netherless blaze powder recipe' is set to true. Delete your" +
|
||||||
|
" config/betterbeginnings/advancedcrafting/main.json file afterward.");
|
||||||
netherlessBlazePowderRecipe = config.getBoolean("Netherless blaze powder recipe", CRAFTING, true,
|
netherlessBlazePowderRecipe = config.getBoolean("Netherless blaze powder recipe", CRAFTING, true,
|
||||||
"Add an alternate, Netherless, but expensive recipe for blaze powder to help ease getting a diamond " +
|
"Add an alternate, Netherless, but expensive recipe for blaze powder to help ease getting a diamond" +
|
||||||
"pick. Still works even if 'Require blaze powder for diamond pick' is false.");
|
" pick. Still works even if 'Require blaze powder for diamond pick' is false." +
|
||||||
|
" Delete your config/betterbeginnings/advancedcrafting/main.json file afterward.");
|
||||||
|
|
||||||
// Smelting
|
// Smelting
|
||||||
canSmelterDoKilnStuff = config.getBoolean("Smelter can make kiln products", SMELTING, false,
|
canSmelterDoKilnStuff = config.getBoolean("Smelter can make kiln products", SMELTING, false,
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.einsteinsci.betterbeginnings.config.json;
|
||||||
|
|
||||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
|
@ -14,10 +15,22 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
public static final AdvancedCraftingConfig INSTANCE = new AdvancedCraftingConfig();
|
public static final AdvancedCraftingConfig INSTANCE = new AdvancedCraftingConfig();
|
||||||
|
|
||||||
|
private static JsonAdvancedCraftingHandler initialRecipes = new JsonAdvancedCraftingHandler();
|
||||||
|
|
||||||
private JsonAdvancedCraftingHandler mainRecipes = new JsonAdvancedCraftingHandler();
|
private JsonAdvancedCraftingHandler mainRecipes = new JsonAdvancedCraftingHandler();
|
||||||
|
private JsonAdvancedCraftingHandler customRecipes = new JsonAdvancedCraftingHandler();
|
||||||
|
|
||||||
private List<JsonAdvancedCraftingHandler> includes = new ArrayList<>();
|
private List<JsonAdvancedCraftingHandler> includes = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void addAdvancedRecipe(ItemStack result, Object[] additionalMaterials, Object... args)
|
||||||
|
{
|
||||||
|
addAdvancedRecipe(result, false, additionalMaterials, args);
|
||||||
|
}
|
||||||
|
public static void addAdvancedRecipe(ItemStack result, boolean hide, Object[] additionalMaterials, Object... args)
|
||||||
|
{
|
||||||
|
initialRecipes.getRecipes().add(new JsonAdvancedRecipe(result, hide, additionalMaterials, args));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSubFolder()
|
public String getSubFolder()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +44,8 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
String json = FileUtil.readAllText(mainf);
|
String json = FileUtil.readAllText(mainf);
|
||||||
if (json == null)
|
if (json == null)
|
||||||
{
|
{
|
||||||
json = "{}";
|
// Kind of inefficient, but it's easiest this way.
|
||||||
|
json = BBJsonLoader.serializeObject(initialRecipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
|
@ -46,14 +60,21 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
@Override
|
@Override
|
||||||
public String getCustomJson(File subfolder)
|
public String getCustomJson(File subfolder)
|
||||||
{
|
{
|
||||||
return "{}";
|
File customf = new File(subfolder, "custom.json");
|
||||||
|
String json = FileUtil.readAllText(customf);
|
||||||
|
if (json == null)
|
||||||
|
{
|
||||||
|
json = "{}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getIncludedJson(File subfolder)
|
public List<String> getIncludedJson(File subfolder)
|
||||||
{
|
{
|
||||||
List<String> res = new ArrayList<>();
|
List<String> res = new ArrayList<>();
|
||||||
for (String fileName : mainRecipes.getIncludes())
|
for (String fileName : customRecipes.getIncludes())
|
||||||
{
|
{
|
||||||
File incf = new File(subfolder, fileName);
|
File incf = new File(subfolder, fileName);
|
||||||
String json = FileUtil.readAllText(incf);
|
String json = FileUtil.readAllText(incf);
|
||||||
|
@ -67,11 +88,16 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
|
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
|
||||||
{
|
{
|
||||||
mainRecipes = BBJsonLoader.deserializeObject(mainJson, JsonAdvancedCraftingHandler.class);
|
mainRecipes = BBJsonLoader.deserializeObject(mainJson, JsonAdvancedCraftingHandler.class);
|
||||||
|
|
||||||
for (JsonAdvancedRecipe j : mainRecipes.getRecipes())
|
for (JsonAdvancedRecipe j : mainRecipes.getRecipes())
|
||||||
{
|
{
|
||||||
j.register();
|
j.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonAdvancedCraftingHandler.class);
|
||||||
|
for (JsonAdvancedRecipe r : customRecipes.getRecipes())
|
||||||
|
{
|
||||||
|
r.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +107,12 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
JsonAdvancedCraftingHandler handler = BBJsonLoader.deserializeObject(json, JsonAdvancedCraftingHandler.class);
|
JsonAdvancedCraftingHandler handler = BBJsonLoader.deserializeObject(json, JsonAdvancedCraftingHandler.class);
|
||||||
|
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
LogUtil.log(Level.ERROR, "Could not deserialize included json.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boolean missingDependencies = false;
|
boolean missingDependencies = false;
|
||||||
for (String mod : handler.getModDependencies())
|
for (String mod : handler.getModDependencies())
|
||||||
{
|
{
|
||||||
|
@ -118,4 +150,9 @@ public class AdvancedCraftingConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
return mainRecipes;
|
return mainRecipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonAdvancedCraftingHandler getCustomRecipes()
|
||||||
|
{
|
||||||
|
return customRecipes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,17 @@ public class JsonAdvancedCraftingHandler
|
||||||
private List<String> modDependencies = new ArrayList<>();
|
private List<String> modDependencies = new ArrayList<>();
|
||||||
|
|
||||||
public JsonAdvancedCraftingHandler()
|
public JsonAdvancedCraftingHandler()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public JsonAdvancedCraftingHandler(boolean addTesting)
|
||||||
{
|
{
|
||||||
// TESTING ONLY
|
if (addTesting)
|
||||||
recipes.add(new JsonAdvancedRecipe(new ItemStack(Items.string, 38),
|
{
|
||||||
new Object[]{new ItemStack(RegisterItems.cloth, 7), "dustRedstone", 13}, "ox ", "xxx", " xo",
|
// TESTING ONLY
|
||||||
'x', Blocks.bedrock, 'o', "nuggetIron"));
|
recipes.add(new JsonAdvancedRecipe(new ItemStack(Items.string, 38),
|
||||||
|
new Object[]{new ItemStack(RegisterItems.cloth, 7), "dustRedstone", 13}, "ox ", "xxx", " xo",
|
||||||
|
'x', Blocks.bedrock, 'o', "nuggetIron"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JsonAdvancedRecipe> getRecipes()
|
public List<JsonAdvancedRecipe> getRecipes()
|
||||||
|
|
|
@ -17,10 +17,16 @@ public class JsonAdvancedRecipe
|
||||||
private List<String> recipe = new ArrayList<>();
|
private List<String> recipe = new ArrayList<>();
|
||||||
private Map<Character, JsonLoadedItem> ingredients = new HashMap<>();
|
private Map<Character, JsonLoadedItem> ingredients = new HashMap<>();
|
||||||
private List<JsonLoadedItemStack> catalysts = new ArrayList<>();
|
private List<JsonLoadedItemStack> catalysts = new ArrayList<>();
|
||||||
|
private boolean hideFromNEI;
|
||||||
|
|
||||||
public JsonAdvancedRecipe(ItemStack output, Object[] catalysts, Object... params)
|
public JsonAdvancedRecipe(ItemStack output, Object[] catalysts, Object... params)
|
||||||
|
{
|
||||||
|
this(output, false, catalysts, params);
|
||||||
|
}
|
||||||
|
public JsonAdvancedRecipe(ItemStack output, boolean hide, Object[] catalysts, Object... params)
|
||||||
{
|
{
|
||||||
this.output = new JsonLoadedItemStack(output);
|
this.output = new JsonLoadedItemStack(output);
|
||||||
|
hideFromNEI = hide;
|
||||||
|
|
||||||
String ore = null;
|
String ore = null;
|
||||||
for (Object obj : catalysts)
|
for (Object obj : catalysts)
|
||||||
|
@ -186,7 +192,7 @@ public class JsonAdvancedRecipe
|
||||||
}
|
}
|
||||||
Object[] params = res.toArray();
|
Object[] params = res.toArray();
|
||||||
|
|
||||||
AdvancedCraftingHandler.addAdvancedRecipe(output.getFirstItemStackOrNull(), addedMats, params);
|
AdvancedCraftingHandler.addAdvancedRecipe(output.getFirstItemStackOrNull(), hideFromNEI, addedMats, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonLoadedItemStack getOutput()
|
public JsonLoadedItemStack getOutput()
|
||||||
|
|
|
@ -118,6 +118,12 @@ public class KilnConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
JsonKilnRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonKilnRecipeHandler.class);
|
JsonKilnRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonKilnRecipeHandler.class);
|
||||||
|
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
LogUtil.log(Level.ERROR, "Could not deserialize included json.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boolean missingDependencies = false;
|
boolean missingDependencies = false;
|
||||||
for (String mod : handler.getModDependencies())
|
for (String mod : handler.getModDependencies())
|
||||||
{
|
{
|
||||||
|
@ -155,4 +161,9 @@ public class KilnConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
return mainRecipes;
|
return mainRecipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonKilnRecipeHandler getCustomRecipes()
|
||||||
|
{
|
||||||
|
return customRecipes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,6 +120,12 @@ public class SmelterConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
JsonSmelterRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonSmelterRecipeHandler.class);
|
JsonSmelterRecipeHandler handler = BBJsonLoader.deserializeObject(json, JsonSmelterRecipeHandler.class);
|
||||||
|
|
||||||
|
if (handler == null)
|
||||||
|
{
|
||||||
|
LogUtil.log(Level.ERROR, "Could not deserialize included json.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boolean missingDependencies = false;
|
boolean missingDependencies = false;
|
||||||
for (String mod : handler.getModDependencies())
|
for (String mod : handler.getModDependencies())
|
||||||
{
|
{
|
||||||
|
@ -157,4 +163,9 @@ public class SmelterConfig implements IJsonConfig
|
||||||
{
|
{
|
||||||
return mainRecipes;
|
return mainRecipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonSmelterRecipeHandler getCustomRecipes()
|
||||||
|
{
|
||||||
|
return customRecipes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,9 +17,7 @@ public class AdvancedCraftingHandler
|
||||||
public List<AdvancedRecipe> recipes = new ArrayList<>();
|
public List<AdvancedRecipe> recipes = new ArrayList<>();
|
||||||
|
|
||||||
public AdvancedCraftingHandler()
|
public AdvancedCraftingHandler()
|
||||||
{
|
{ }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addAdvancedRecipe(ItemStack result, Object[] additionalMaterials, Object... args)
|
public static void addAdvancedRecipe(ItemStack result, Object[] additionalMaterials, Object... args)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue