Moved smelter recipes to be 100% on config.
parent
4579300e00
commit
f61d34b90a
|
@ -15,10 +15,16 @@ public class JsonSmelterRecipeHandler
|
|||
private List<String> modDependencies = new ArrayList<>();
|
||||
|
||||
public JsonSmelterRecipeHandler()
|
||||
{ }
|
||||
|
||||
public JsonSmelterRecipeHandler(boolean addTesting)
|
||||
{
|
||||
if (addTesting)
|
||||
{
|
||||
// TESTING ONLY //
|
||||
recipes.add(new JsonSmelterRecipe(new ItemStack(Blocks.bedrock), new ItemStack(Items.golden_hoe), 0.5f, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public List<JsonSmelterRecipe> getRecipes()
|
||||
{
|
||||
|
|
|
@ -2,6 +2,9 @@ package net.einsteinsci.betterbeginnings.config.json;
|
|||
|
||||
import net.einsteinsci.betterbeginnings.util.FileUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.LogUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
@ -14,9 +17,31 @@ public class SmelterConfig implements IJsonConfig
|
|||
{
|
||||
public static final SmelterConfig INSTANCE = new SmelterConfig();
|
||||
|
||||
private static JsonSmelterRecipeHandler initialRecipes = new JsonSmelterRecipeHandler();
|
||||
|
||||
private JsonSmelterRecipeHandler mainRecipes = new JsonSmelterRecipeHandler();
|
||||
private JsonSmelterRecipeHandler customRecipes = new JsonSmelterRecipeHandler();
|
||||
|
||||
private List<JsonSmelterRecipeHandler> includes = new ArrayList<>();
|
||||
|
||||
public static void addRecipe(String input, ItemStack output, float experience, int boosters, int bonus)
|
||||
{
|
||||
initialRecipes.getRecipes().add(new JsonSmelterRecipe(JsonLoadedItem.makeOreDictionary(input),
|
||||
new JsonLoadedItemStack(output), experience, boosters, bonus));
|
||||
}
|
||||
public static void addRecipe(ItemStack input, ItemStack output, float experience, int boosters, int bonus)
|
||||
{
|
||||
initialRecipes.getRecipes().add(new JsonSmelterRecipe(input, output, experience, boosters, bonus));
|
||||
}
|
||||
public static void addRecipe(Item input, ItemStack output, float experience, int boosters, int bonus)
|
||||
{
|
||||
initialRecipes.getRecipes().add(new JsonSmelterRecipe(new ItemStack(input), output, experience, boosters, bonus));
|
||||
}
|
||||
public static void addRecipe(Block input, ItemStack output, float experience, int boosters, int bonus)
|
||||
{
|
||||
initialRecipes.getRecipes().add(new JsonSmelterRecipe(new ItemStack(input), output, experience, boosters, bonus));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubFolder()
|
||||
{
|
||||
|
@ -30,7 +55,8 @@ public class SmelterConfig implements IJsonConfig
|
|||
String json = FileUtil.readAllText(mainf);
|
||||
if (json == null)
|
||||
{
|
||||
json = "{}";
|
||||
// Kind of inefficient, but it's easiest this way.
|
||||
json = BBJsonLoader.serializeObject(initialRecipes);
|
||||
}
|
||||
|
||||
return json;
|
||||
|
@ -45,14 +71,21 @@ public class SmelterConfig implements IJsonConfig
|
|||
@Override
|
||||
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
|
||||
public List<String> getIncludedJson(File subfolder)
|
||||
{
|
||||
List<String> res = new ArrayList<>();
|
||||
for (String fileName : mainRecipes.getIncludes())
|
||||
for (String fileName : customRecipes.getIncludes())
|
||||
{
|
||||
File incf = new File(subfolder, fileName);
|
||||
String json = FileUtil.readAllText(incf);
|
||||
|
@ -77,6 +110,13 @@ public class SmelterConfig implements IJsonConfig
|
|||
{
|
||||
j.register();
|
||||
}
|
||||
|
||||
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonSmelterRecipeHandler.class);
|
||||
|
||||
for (JsonSmelterRecipe j : customRecipes.getRecipes())
|
||||
{
|
||||
j.register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.config.json.SmelterConfig;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemCharredMeat;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -139,8 +140,8 @@ public class RegisterRecipes
|
|||
private static void addSmelterRecipes()
|
||||
{
|
||||
// Vanilla Ore Recipes (keep the result vanilla to prevent weirdness)
|
||||
SmelterRecipeHandler.addRecipe("oreIron", new ItemStack(Items.iron_ingot), 0.7f, 1, 1);
|
||||
SmelterRecipeHandler.addRecipe("oreGold", new ItemStack(Items.gold_ingot), 1.0f, 2, 1);
|
||||
SmelterConfig.addRecipe("oreIron", new ItemStack(Items.iron_ingot), 0.7f, 1, 1);
|
||||
SmelterConfig.addRecipe("oreGold", new ItemStack(Items.gold_ingot), 1.0f, 2, 1);
|
||||
|
||||
// Modded Ore Recipes
|
||||
RegisterHelper.registerSmelterOreRecipe("oreCopper", "ingotCopper", 0.6f, 1, 1);
|
||||
|
@ -154,29 +155,29 @@ public class RegisterRecipes
|
|||
// Recipes that might be better suited in Kiln only
|
||||
if (BBConfig.canSmelterDoKilnStuff)
|
||||
{
|
||||
SmelterRecipeHandler.addRecipe(new ItemStack(Blocks.sand, 1, 0),
|
||||
SmelterConfig.addRecipe(new ItemStack(Blocks.sand, 1, 0),
|
||||
new ItemStack(Blocks.glass), 0.1f, 1, 0);
|
||||
SmelterRecipeHandler.addRecipe(new ItemStack(Blocks.sand, 1, 1),
|
||||
SmelterConfig.addRecipe(new ItemStack(Blocks.sand, 1, 1),
|
||||
new ItemStack(Blocks.stained_glass, 1, 1), 0.1f, 1, 0); // Red sand makes orange stained glass.
|
||||
SmelterRecipeHandler.addRecipe(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.25f, 1, 1);
|
||||
SmelterRecipeHandler.addRecipe(Blocks.stonebrick, new ItemStack(Blocks.stonebrick, 1, 2), 0.1f, 1, 0);
|
||||
SmelterConfig.addRecipe(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.25f, 1, 1);
|
||||
SmelterConfig.addRecipe(Blocks.stonebrick, new ItemStack(Blocks.stonebrick, 1, 2), 0.1f, 1, 0);
|
||||
|
||||
SmelterRecipeHandler.addRecipe("cobblestone", new ItemStack(Blocks.stone), 0.1f, 0, 0);
|
||||
SmelterRecipeHandler.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.3f, 0, 0);
|
||||
SmelterRecipeHandler.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35f, 0, 0);
|
||||
SmelterRecipeHandler.addRecipe(new ItemStack(Blocks.sponge, 1, 1),
|
||||
SmelterConfig.addRecipe("cobblestone", new ItemStack(Blocks.stone), 0.1f, 0, 0);
|
||||
SmelterConfig.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.3f, 0, 0);
|
||||
SmelterConfig.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35f, 0, 0);
|
||||
SmelterConfig.addRecipe(new ItemStack(Blocks.sponge, 1, 1),
|
||||
new ItemStack(Blocks.sponge, 1, 0), 0.1f, 0, 0);
|
||||
SmelterRecipeHandler.addRecipe(new ItemStack(Blocks.stonebrick, 1, 0),
|
||||
SmelterConfig.addRecipe(new ItemStack(Blocks.stonebrick, 1, 0),
|
||||
new ItemStack(Blocks.stonebrick, 1, 2), 0.1f, 0, 0);
|
||||
}
|
||||
|
||||
// Silk touch recipes
|
||||
SmelterRecipeHandler.addRecipe("oreCoal", new ItemStack(Items.coal, 1), 0.25f, 2, 1);
|
||||
SmelterRecipeHandler.addRecipe("oreQuartz", new ItemStack(Items.quartz, 2), 0.4f, 2, 2);
|
||||
SmelterRecipeHandler.addRecipe("oreLapis", new ItemStack(Items.dye, 8, 4), 0.5f, 2, 3);
|
||||
SmelterRecipeHandler.addRecipe("oreRedstone", new ItemStack(Items.redstone, 4), 0.8f, 2, 2);
|
||||
SmelterRecipeHandler.addRecipe("oreDiamond", new ItemStack(Items.diamond, 1), 1.0f, 3, 1);
|
||||
SmelterRecipeHandler.addRecipe("oreEmerald", new ItemStack(Items.emerald, 1), 1.0f, 3, 1);
|
||||
SmelterConfig.addRecipe("oreCoal", new ItemStack(Items.coal, 1), 0.25f, 2, 1);
|
||||
SmelterConfig.addRecipe("oreQuartz", new ItemStack(Items.quartz, 2), 0.4f, 2, 2);
|
||||
SmelterConfig.addRecipe("oreLapis", new ItemStack(Items.dye, 8, 4), 0.5f, 2, 3);
|
||||
SmelterConfig.addRecipe("oreRedstone", new ItemStack(Items.redstone, 4), 0.8f, 2, 2);
|
||||
SmelterConfig.addRecipe("oreDiamond", new ItemStack(Items.diamond, 1), 1.0f, 3, 1);
|
||||
SmelterConfig.addRecipe("oreEmerald", new ItemStack(Items.emerald, 1), 1.0f, 3, 1);
|
||||
|
||||
// Silk touch recipes (modded)
|
||||
RegisterHelper.registerSmelterOreRecipe("oreRuby", "gemRuby", 0.8f, 2, 1);
|
||||
|
|
Loading…
Reference in New Issue