Moved kiln ore recipes to be 100% on config.

master
sealedinterface 2016-05-20 19:00:57 -07:00
parent 8bb72c3add
commit 51ce6f9691
8 changed files with 66 additions and 52 deletions

View File

@ -63,12 +63,6 @@ public class AdvancedCraftingConfig implements IJsonConfig
return res;
}
@Override
public boolean isOnlyMain()
{
return true;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{

View File

@ -62,12 +62,6 @@ public class BrickOvenConfig implements IJsonConfig
return res;
}
@Override
public boolean isOnlyMain()
{
return true;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{

View File

@ -15,8 +15,6 @@ public interface IJsonConfig
List<String> getIncludedJson(File subfolder);
boolean isOnlyMain();
void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson);
void loadIncludedConfig(FMLInitializationEvent e, List<String> includedJsons);

View File

@ -15,9 +15,15 @@ public class JsonKilnRecipeHandler
private List<String> modDependencies = new ArrayList<>();
public JsonKilnRecipeHandler()
{ }
public JsonKilnRecipeHandler(boolean includeTesting)
{
// TESTING ONLY
recipes.add(new JsonKilnRecipe(new ItemStack(Blocks.bedrock), new ItemStack(Items.blaze_rod), 0.5f));
if (includeTesting)
{
// TESTING ONLY
recipes.add(new JsonKilnRecipe(new ItemStack(Blocks.bedrock), new ItemStack(Items.blaze_rod), 0.5f));
}
}
public List<JsonKilnRecipe> getRecipes()

View File

@ -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;
@ -21,6 +24,24 @@ public class KilnConfig implements IJsonConfig
private List<JsonKilnRecipeHandler> includes = new ArrayList<>();
public static void addRecipe(ItemStack input, ItemStack output, float xp)
{
initialRecipes.getRecipes().add(new JsonKilnRecipe(input, output, xp));
}
public static void addRecipe(Item input, ItemStack output, float xp)
{
addRecipe(new ItemStack(input), output, xp);
}
public static void addRecipe(Block input, ItemStack output, float xp)
{
addRecipe(new ItemStack(input), output, xp);
}
public static void addRecipe(String input, ItemStack output, float xp)
{
initialRecipes.getRecipes().add(new JsonKilnRecipe(JsonLoadedItem.makeOreDictionary(input),
new JsonLoadedItemStack(output), xp));
}
@Override
public String getSubFolder()
{
@ -50,14 +71,21 @@ public class KilnConfig 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);
@ -67,21 +95,20 @@ public class KilnConfig implements IJsonConfig
return res;
}
@Override
public boolean isOnlyMain()
{
return true;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
mainRecipes = BBJsonLoader.deserializeObject(mainJson, JsonKilnRecipeHandler.class);
for (JsonKilnRecipe j : mainRecipes.getRecipes())
{
j.register();
}
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonKilnRecipeHandler.class);
for (JsonKilnRecipe r : customRecipes.getRecipes())
{
r.register();
}
}
@Override

View File

@ -95,12 +95,6 @@ public class SmelterConfig implements IJsonConfig
return res;
}
@Override
public boolean isOnlyMain()
{
return true;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{

View File

@ -1,6 +1,7 @@
package net.einsteinsci.betterbeginnings.register;
import net.einsteinsci.betterbeginnings.config.BBConfig;
import net.einsteinsci.betterbeginnings.config.json.KilnConfig;
import net.einsteinsci.betterbeginnings.config.json.SmelterConfig;
import net.einsteinsci.betterbeginnings.items.ItemCharredMeat;
import net.einsteinsci.betterbeginnings.register.recipe.*;
@ -74,27 +75,27 @@ public class RegisterRecipes
private static void addKilnRecipes()
{
KilnRecipeHandler.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.35f);
KilnRecipeHandler.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.1f);
KilnRecipeHandler.addRecipe("cobblestone", new ItemStack(Blocks.stone), 0.1f);
KilnRecipeHandler.addRecipe(new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 2), 0.1f);
KilnRecipeHandler.addRecipe(Blocks.cactus, new ItemStack(Items.dye, 1, 2), 0.1f);
KilnRecipeHandler.addRecipe("logWood", new ItemStack(Items.coal, 1, 1), 0.15f);
KilnRecipeHandler.addRecipe(Blocks.sand, new ItemStack(Blocks.glass), 0.1f);
KilnRecipeHandler.addRecipe(new ItemStack(Blocks.sponge, 1, 1), new ItemStack(Blocks.sponge, 1, 0), 0.1f);
KilnRecipeHandler.addRecipe(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.1f);
KilnConfig.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.35f);
KilnConfig.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.1f);
KilnConfig.addRecipe("cobblestone", new ItemStack(Blocks.stone), 0.1f);
KilnConfig.addRecipe(new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 2), 0.1f);
KilnConfig.addRecipe(Blocks.cactus, new ItemStack(Items.dye, 1, 2), 0.1f);
KilnConfig.addRecipe("logWood", new ItemStack(Items.coal, 1, 1), 0.15f);
KilnConfig.addRecipe(Blocks.sand, new ItemStack(Blocks.glass), 0.1f);
KilnConfig.addRecipe(new ItemStack(Blocks.sponge, 1, 1), new ItemStack(Blocks.sponge, 1, 0), 0.1f);
KilnConfig.addRecipe(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.1f);
KilnRecipeHandler.addRecipe(Items.beef, new ItemStack(RegisterItems.charredMeat), 0.1f);
KilnRecipeHandler.addRecipe(Items.porkchop, new ItemStack(RegisterItems.charredMeat), 0.1f);
KilnRecipeHandler.addRecipe(Items.chicken, new ItemStack(RegisterItems.charredMeat, 1,
KilnConfig.addRecipe(Items.beef, new ItemStack(RegisterItems.charredMeat), 0.1f);
KilnConfig.addRecipe(Items.porkchop, new ItemStack(RegisterItems.charredMeat), 0.1f);
KilnConfig.addRecipe(Items.chicken, new ItemStack(RegisterItems.charredMeat, 1,
ItemCharredMeat.META_CHICKEN), 0.1f);
KilnRecipeHandler.addRecipe(new ItemStack(Items.fish, 1, 0), new ItemStack(RegisterItems.charredMeat, 1,
KilnConfig.addRecipe(new ItemStack(Items.fish, 1, 0), new ItemStack(RegisterItems.charredMeat, 1,
ItemCharredMeat.META_FISH), 0.1f);
KilnRecipeHandler.addRecipe(new ItemStack(Items.fish, 1, 1), new ItemStack(RegisterItems.charredMeat, 1,
KilnConfig.addRecipe(new ItemStack(Items.fish, 1, 1), new ItemStack(RegisterItems.charredMeat, 1,
ItemCharredMeat.META_FISH), 0.1f);
KilnRecipeHandler.addRecipe(Items.rabbit, new ItemStack(RegisterItems.charredMeat, 1,
KilnConfig.addRecipe(Items.rabbit, new ItemStack(RegisterItems.charredMeat, 1,
ItemCharredMeat.META_RABBIT), 0.1f);
KilnRecipeHandler.addRecipe(Items.mutton, new ItemStack(RegisterItems.charredMeat, 1,
KilnConfig.addRecipe(Items.mutton, new ItemStack(RegisterItems.charredMeat, 1,
ItemCharredMeat.META_MUTTON), 0.1f);
}

View File

@ -20,11 +20,6 @@ public class KilnRecipeHandler
// nothing here
}
public static void addRecipe(Item input, ItemStack output, float experience)
{
instance().addLists(input, output, experience);
}
public void addLists(Item input, ItemStack itemStack, float experience)
{
putLists(new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE), itemStack, experience);
@ -49,6 +44,11 @@ public class KilnRecipeHandler
}
}
public static void addRecipe(Item input, ItemStack output, float experience)
{
instance().addLists(input, output, experience);
}
public static void addRecipe(Block input, ItemStack output, float experience)
{
instance().addLists(Item.getItemFromBlock(input), output, experience);