diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 61b18a928..0b2970d89 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -355,6 +355,7 @@ public final class ModBlocks { r.register(new ItemBlockMod(enchantedSoil).setRegistryName(enchantedSoil.getRegistryName())); r.register(new ItemBlockWithMetadataAndName(petalBlock).setRegistryName(petalBlock.getRegistryName())); r.register(new ItemBlockMod(corporeaIndex).setRegistryName(corporeaIndex.getRegistryName())); + r.register(new ItemBlockMod(corporeaFunnel).setRegistryName(corporeaFunnel.getRegistryName())); r.register(new ItemBlockWithMetadataAndName(mushroom).setRegistryName(mushroom.getRegistryName())); r.register(new ItemBlockMod(pump).setRegistryName(pump.getRegistryName())); r.register(new ItemBlockWithMetadataAndName(doubleFlower1).setRegistryName(doubleFlower1.getRegistryName())); diff --git a/src/main/java/vazkii/botania/common/crafting/DarkQuartzConditionFactory.java b/src/main/java/vazkii/botania/common/crafting/DarkQuartzConditionFactory.java new file mode 100644 index 000000000..3304e80fd --- /dev/null +++ b/src/main/java/vazkii/botania/common/crafting/DarkQuartzConditionFactory.java @@ -0,0 +1,25 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.common.crafting; + +import com.google.gson.JsonObject; +import net.minecraft.util.JsonUtils; +import net.minecraftforge.common.crafting.IConditionFactory; +import net.minecraftforge.common.crafting.JsonContext; +import vazkii.botania.common.core.handler.ConfigHandler; + +import java.util.function.BooleanSupplier; + +public class DarkQuartzConditionFactory implements IConditionFactory { + @Override + public BooleanSupplier parse(JsonContext context, JsonObject json) { + boolean value = JsonUtils.getBoolean(json , "value", true); + return () -> ConfigHandler.darkQuartzEnabled == value; + } +} diff --git a/src/main/java/vazkii/botania/common/crafting/FluxfieldConditionFactory.java b/src/main/java/vazkii/botania/common/crafting/FluxfieldConditionFactory.java new file mode 100644 index 000000000..a66ab0009 --- /dev/null +++ b/src/main/java/vazkii/botania/common/crafting/FluxfieldConditionFactory.java @@ -0,0 +1,25 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.common.crafting; + +import com.google.gson.JsonObject; +import net.minecraft.util.JsonUtils; +import net.minecraftforge.common.crafting.IConditionFactory; +import net.minecraftforge.common.crafting.JsonContext; +import vazkii.botania.common.core.handler.ConfigHandler; + +import java.util.function.BooleanSupplier; + +public class FluxfieldConditionFactory implements IConditionFactory { + @Override + public BooleanSupplier parse(JsonContext context, JsonObject json) { + boolean value = JsonUtils.getBoolean(json , "value", true); + return () -> ConfigHandler.fluxfieldEnabled == value; + } +} diff --git a/src/main/java/vazkii/botania/common/crafting/GardenOfGlassConditionFactory.java b/src/main/java/vazkii/botania/common/crafting/GardenOfGlassConditionFactory.java index 247fcaf81..28398a60a 100644 --- a/src/main/java/vazkii/botania/common/crafting/GardenOfGlassConditionFactory.java +++ b/src/main/java/vazkii/botania/common/crafting/GardenOfGlassConditionFactory.java @@ -1,3 +1,11 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ package vazkii.botania.common.crafting; import com.google.gson.JsonObject; diff --git a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java index d37409140..7588d651e 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModCraftingRecipes.java @@ -393,11 +393,11 @@ public final class ModCraftingRecipes { r.register(new TerraPickTippingRecipe().setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "terra_pick_tipping"))); RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, RecipeSorter.Category.SHAPELESS, ""); - - if (true) { - return; + for(int i = 0; i < 8; i++) { + GameRegistry.addSmelting(new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), 0.1F); } + /* // Wand of the Forest Recipes for(int i = 0; i < 16; i++) for(int j = 0; j < 16; j++) { @@ -409,19 +409,8 @@ public final class ModCraftingRecipes { } recipesTwigWand = BotaniaAPI.getLatestAddedRecipes(256); - // Mana Tablet Recipe - addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", "SPS", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'P', LibOreDict.MANA_PEARL); - addOreDictRecipe(new ItemStack(ModItems.manaTablet, 1, 10000), - "SSS", "SDS", "SSS", - 'S', LibOreDict.LIVING_ROCK, - 'D', LibOreDict.MANA_DIAMOND); - recipesManaTablet = BotaniaAPI.getLatestAddedRecipes(2); - // Terrasteel Armor Recipes - /*RecipeSorter.register("botania:armorUpgrade", ArmorUpgradeRecipe.class, RecipeSorter.Category.SHAPED, ""); + RecipeSorter.register("botania:armorUpgrade", ArmorUpgradeRecipe.class, RecipeSorter.Category.SHAPED, ""); GameRegistry.addRecipe(new ArmorUpgradeRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), "TRT", "SAS", " S ", 'T', LibOreDict.LIVINGWOOD_TWIG, @@ -468,19 +457,15 @@ public final class ModCraftingRecipes { // Greater Mana Band Recipe /*RecipeSorter.register("botania:manaUpgradeShapeless", ShapelessManaUpgradeRecipe.class, RecipeSorter.Category.SHAPELESS, ""); GameRegistry.addRecipe(new ShapelessManaUpgradeRecipe(new ItemStack(ModItems.manaRingGreater), LibOreDict.TERRA_STEEL, new ItemStack(ModItems.manaRing, 1, Short.MAX_VALUE))); - recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe();*/ + recipeGreaterManaRing = BotaniaAPI.getLatestAddedRecipe(); // Terra Shatterer Recipe - /*GameRegistry.addRecipe(new ManaUpgradeRecipe(new ItemStack(ModItems.terraPick), + GameRegistry.addRecipe(new ManaUpgradeRecipe(new ItemStack(ModItems.terraPick), "ITI", "ILI", " L ", 'T', new ItemStack(ModItems.manaTablet, 1, Short.MAX_VALUE), 'I', LibOreDict.TERRA_STEEL, 'L', LibOreDict.LIVINGWOOD_TWIG)); - recipeTerraPick = BotaniaAPI.getLatestAddedRecipe();*/ - - // Quartz Recipes - if(ConfigHandler.darkQuartzEnabled) - recipeDarkQuartz = addQuartzRecipes(0, Items.COAL, ModFluffBlocks.darkQuartz, ModFluffBlocks.darkQuartzStairs, ModFluffBlocks.darkQuartzSlab); + recipeTerraPick = BotaniaAPI.getLatestAddedRecipe(); // Rod of the Seas Recipe addOreDictRecipe(new ItemStack(ModItems.waterRod), @@ -490,35 +475,7 @@ public final class ModCraftingRecipes { 'R', LibOreDict.RUNE[0]); recipeWaterRod = BotaniaAPI.getLatestAddedRecipe(); - // Mana Fluxfield Recipe - if(ConfigHandler.fluxfieldEnabled) { - addOreDictRecipe(new ItemStack(ModBlocks.rfGenerator), - "SRS", "RMR", "SRS", - 'S', LibOreDict.LIVING_ROCK, - 'M', LibOreDict.MANA_STEEL, - 'R', "blockRedstone"); - recipeRFGenerator = BotaniaAPI.getLatestAddedRecipe(); - } - - - // Corporea Funnel Recipe - addShapelessRecipe(new ItemStack(ModBlocks.corporeaFunnel), new ItemStack(Blocks.DROPPER), new ItemStack(ModItems.corporeaSpark)); - recipeCorporeaFunnel = BotaniaAPI.getLatestAddedRecipe(); - - // Cacophonium Recipe - if(OreDictionary.getOres("ingotBrass").isEmpty()) - addOreDictRecipe(new ItemStack(ModItems.cacophonium), - " G ", "GNG", "GG ", - 'G', "ingotGold", - 'N', new ItemStack(Blocks.NOTEBLOCK)); - else addOreDictRecipe(new ItemStack(ModItems.cacophonium), - " G ", "GNG", "GG ", - 'G', "ingotBrass", - 'N', new ItemStack(Blocks.NOTEBLOCK)); - recipeCacophonium = BotaniaAPI.getLatestAddedRecipe(); - - /////////////////////////////////////////////////////////////////////////////////////////////////////////// - + todo if tc ever comes back? // Revealing Helmet Recipes if(Botania.thaumcraftLoaded) { Item goggles = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "goggles")); @@ -527,222 +484,6 @@ public final class ModCraftingRecipes { addShapelessRecipe(new ItemStack(ModItems.terrasteelHelmRevealing), new ItemStack(ModItems.terrasteelHelm), goggles); addShapelessRecipe(new ItemStack(ModItems.elementiumHelmRevealing), new ItemStack(ModItems.elementiumHelm), goggles); } - - // Biome Stone Recipes - for(int i = 0; i < 8; i++) { - GameRegistry.addSmelting(new ItemStack(ModFluffBlocks.biomeStoneA, 1, i + 8), new ItemStack(ModFluffBlocks.biomeStoneA, 1, i), 0.1F); - } - - generateConstants(); + */ } - - private static void addStairsAndSlabs(Block block, int meta, Block stairs, Block slab) { - addShapedRecipe(new ItemStack(slab, 6), - "QQQ", - 'Q', new ItemStack(block, 1, meta)); - addShapedRecipe(new ItemStack(stairs, 4), - " Q", " QQ", "QQQ", - 'Q', new ItemStack(block, 1, meta)); - addShapedRecipe(new ItemStack(stairs, 4), - "Q ", "QQ ", "QQQ", - 'Q', new ItemStack(block, 1, meta)); - addShapedRecipe(new ItemStack(block, 1, meta), - "Q", "Q", - 'Q', new ItemStack(slab)); - } - - private static IRecipe addQuartzRecipes(int meta, Item req, Block block, Block stairs, Block slab) { - addShapedRecipe(new ItemStack(block), - "QQ", "QQ", - 'Q', LibOreDict.QUARTZ[meta]); - addShapedRecipe(new ItemStack(block, 2, 2), - "Q", "Q", - 'Q', block); - addShapedRecipe(new ItemStack(block, 1, 1), - "Q", "Q", - 'Q', slab); - addStairsAndSlabs(block, 0, stairs, slab); - - if(req != null) { - if(req == Items.COAL) - addShapedRecipe(new ItemStack(ModItems.quartz, 8, meta), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', new ItemStack(req, 1, 1)); - addShapedRecipe(new ItemStack(ModItems.quartz, 8, meta), - "QQQ", "QCQ", "QQQ", - 'Q', "gemQuartz", - 'C', req); - return BotaniaAPI.getLatestAddedRecipe(); - } - return null; - } - - private static void addOreDictRecipe(ItemStack output, Object... recipe) { - addShapedRecipe(output, recipe); - } - - private static void addShapelessOreDictRecipe(ItemStack output, Object... recipe) { - addShapelessRecipe(output, recipe); - } - - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - private static File RECIPE_DIR = null; - private static final Set USED_OD_NAMES = new TreeSet<>(); - - private static void setupDir() { - if (RECIPE_DIR == null) { - RECIPE_DIR = ConfigHandler.config.getConfigFile().toPath().resolve("../recipes/").toFile(); - } - - if (!RECIPE_DIR.exists()) { - RECIPE_DIR.mkdir(); - } - } - - private static void addShapedRecipe(ItemStack result, Object... components) { - setupDir(); - - // GameRegistry.addShapedRecipe(result, components); - - Map json = new HashMap<>(); - - List pattern = new ArrayList<>(); - int i = 0; - while (i < components.length && components[i] instanceof String) { - pattern.add((String) components[i]); - i++; - } - json.put("pattern", pattern); - - boolean isOreDict = false; - Map> key = new HashMap<>(); - Character curKey = null; - for (; i < components.length; i++) { - Object o = components[i]; - if (o instanceof Character) { - if (curKey != null) - throw new IllegalArgumentException("Provided two char keys in a row"); - curKey = (Character) o; - } else { - if (curKey == null) - throw new IllegalArgumentException("Providing object without a char key"); - if (o instanceof String) - isOreDict = true; - key.put(Character.toString(curKey), serializeItem(o)); - curKey = null; - } - } - json.put("key", key); - json.put("type", isOreDict ? "forge:ore_shaped" : "minecraft:crafting_shaped"); - json.put("result", serializeItem(result)); - - // names the json the same name as the output's registry name - // repeatedly adds _alt if a file already exists - // janky I know but it works - String suffix = result.getItem().getHasSubtypes() ? "_" + result.getItemDamage() : ""; - File f = new File(RECIPE_DIR, result.getItem().getRegistryName().getResourcePath() + suffix + ".json"); - - while (f.exists()) { - suffix += "_alt"; - f = new File(RECIPE_DIR, result.getItem().getRegistryName().getResourcePath() + suffix + ".json"); - } - - try (FileWriter w = new FileWriter(f)) { - GSON.toJson(json, w); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void addShapelessRecipe(ItemStack result, Object... components) - { - setupDir(); - - // addShapelessRecipe(result, components); - - Map json = new HashMap<>(); - - boolean isOreDict = false; - List> ingredients = new ArrayList<>(); - for (Object o : components) { - if (o instanceof String) - isOreDict = true; - ingredients.add(serializeItem(o)); - } - json.put("ingredients", ingredients); - json.put("type", isOreDict ? "forge:ore_shapeless" : "minecraft:crafting_shapeless"); - json.put("result", serializeItem(result)); - - // names the json the same name as the output's registry name - // repeatedly adds _alt if a file already exists - // janky I know but it works - String suffix = result.getItem().getHasSubtypes() ? "_" + result.getItemDamage() : ""; - File f = new File(RECIPE_DIR, result.getItem().getRegistryName().getResourcePath() + suffix + ".json"); - - while (f.exists()) { - suffix += "_alt"; - f = new File(RECIPE_DIR, result.getItem().getRegistryName().getResourcePath() + suffix + ".json"); - } - - - try (FileWriter w = new FileWriter(f)) { - GSON.toJson(json, w); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static Map serializeItem(Object thing) { - if (thing instanceof Item) { - return serializeItem(new ItemStack((Item) thing)); - } - if (thing instanceof Block) { - return serializeItem(new ItemStack((Block) thing)); - } - if (thing instanceof ItemStack) { - ItemStack stack = (ItemStack) thing; - Map ret = new HashMap<>(); - ret.put("item", stack.getItem().getRegistryName().toString()); - if (stack.getItem().getHasSubtypes() || stack.getItemDamage() != 0) { - ret.put("data", stack.getItemDamage()); - } - if (stack.getCount() > 1) { - ret.put("count", stack.getCount()); - } - - // this only works when serializing nbt for results, not for ingredients - // for ingredients, the type tag in the caller needs to be changed to item_nbt - if (stack.hasTagCompound()) { - ret.put("nbt", stack.getTagCompound().toString()); - } - - return ret; - } - if (thing instanceof String) { - Map ret = new HashMap<>(); - USED_OD_NAMES.add((String) thing); - ret.put("item", "#" + ((String) thing).toUpperCase(Locale.ROOT)); - return ret; - } - - throw new IllegalArgumentException("Not a block, item, stack, or od name"); - } - - private static void generateConstants() { - List> json = new ArrayList<>(); - for (String s : USED_OD_NAMES) { - Map entry = new HashMap<>(); - entry.put("name", s.toUpperCase(Locale.ROOT)); - entry.put("ingredient", ImmutableMap.of("type", "forge:ore_dict", "ore", s)); - json.add(entry); - } - - try (FileWriter w = new FileWriter(new File(RECIPE_DIR, "_constants.json"))) { - GSON.toJson(json, w); - } catch (IOException e) { - e.printStackTrace(); - } - } - } diff --git a/src/main/resources/assets/botania/recipes/_constants.json b/src/main/resources/assets/botania/recipes/_constants.json index 4ac0f2b59..f52ad7d7d 100644 --- a/src/main/resources/assets/botania/recipes/_constants.json +++ b/src/main/resources/assets/botania/recipes/_constants.json @@ -181,6 +181,13 @@ }, "name": "GRAVEL" }, + { + "ingredient": { + "type": "forge:ore_dict", + "ore": "ingotBrass" + }, + "name": "INGOTBRASS" + }, { "ingredient": { "type": "forge:ore_dict", diff --git a/src/main/resources/assets/botania/recipes/_factories.json b/src/main/resources/assets/botania/recipes/_factories.json index 983245595..12ea45195 100644 --- a/src/main/resources/assets/botania/recipes/_factories.json +++ b/src/main/resources/assets/botania/recipes/_factories.json @@ -1,5 +1,7 @@ { "conditions": { - "garden_of_glass": "vazkii.botania.common.crafting.GardenOfGlassConditionFactory" + "garden_of_glass": "vazkii.botania.common.crafting.GardenOfGlassConditionFactory", + "dark_quartz_enabled": "vazkii.botania.common.crafting.DarkQuartzConditionFactory", + "fluxfield_enabled": "vazkii.botania.common.crafting.FluxfieldConditionFactory" } } \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/cacophonium.json b/src/main/resources/assets/botania/recipes/cacophonium.json index 30c3aca89..0d2e658b3 100644 --- a/src/main/resources/assets/botania/recipes/cacophonium.json +++ b/src/main/resources/assets/botania/recipes/cacophonium.json @@ -9,9 +9,14 @@ ], "type": "forge:ore_shaped", "key": { - "G": { - "item": "#INGOTGOLD" - }, + "G": [ + { + "item": "#INGOTGOLD" + }, + { + "item": "#INGOTBRASS" + } + ], "N": { "item": "minecraft:noteblock" } diff --git a/src/main/resources/assets/botania/recipes/corporeafunnel.json b/src/main/resources/assets/botania/recipes/corporeafunnel.json new file mode 100644 index 000000000..e0d2db26c --- /dev/null +++ b/src/main/resources/assets/botania/recipes/corporeafunnel.json @@ -0,0 +1,15 @@ +{ + "result": { + "item": "botania:corporeafunnel" + }, + "ingredients": [ + { + "item": "minecraft:dropper" + }, + { + "item": "botania:corporeaspark", + "data": 0 + } + ], + "type": "minecraft:crafting_shapeless" +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/recipes/quartzslabdarkhalf_0.json b/src/main/resources/assets/botania/recipes/quartzslabdarkhalf_0.json index 6e84a3acb..78e5b6b31 100644 --- a/src/main/resources/assets/botania/recipes/quartzslabdarkhalf_0.json +++ b/src/main/resources/assets/botania/recipes/quartzslabdarkhalf_0.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartzslabdarkhalf", "data": 0, diff --git a/src/main/resources/assets/botania/recipes/quartzstairsdark.json b/src/main/resources/assets/botania/recipes/quartzstairsdark.json index 72afb9456..b025c719f 100644 --- a/src/main/resources/assets/botania/recipes/quartzstairsdark.json +++ b/src/main/resources/assets/botania/recipes/quartzstairsdark.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartzstairsdark", "count": 4 diff --git a/src/main/resources/assets/botania/recipes/quartztypedark_0.json b/src/main/resources/assets/botania/recipes/quartztypedark_0.json index f28cd6c34..f5851042a 100644 --- a/src/main/resources/assets/botania/recipes/quartztypedark_0.json +++ b/src/main/resources/assets/botania/recipes/quartztypedark_0.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartztypedark", "data": 0 diff --git a/src/main/resources/assets/botania/recipes/quartztypedark_0_alt.json b/src/main/resources/assets/botania/recipes/quartztypedark_0_alt.json index fad8e9638..9da2981be 100644 --- a/src/main/resources/assets/botania/recipes/quartztypedark_0_alt.json +++ b/src/main/resources/assets/botania/recipes/quartztypedark_0_alt.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartztypedark", "data": 0 diff --git a/src/main/resources/assets/botania/recipes/quartztypedark_1.json b/src/main/resources/assets/botania/recipes/quartztypedark_1.json index 605db34ed..09699fd33 100644 --- a/src/main/resources/assets/botania/recipes/quartztypedark_1.json +++ b/src/main/resources/assets/botania/recipes/quartztypedark_1.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartztypedark", "data": 1 diff --git a/src/main/resources/assets/botania/recipes/quartztypedark_2.json b/src/main/resources/assets/botania/recipes/quartztypedark_2.json index a05533db0..a3756dbe4 100644 --- a/src/main/resources/assets/botania/recipes/quartztypedark_2.json +++ b/src/main/resources/assets/botania/recipes/quartztypedark_2.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:dark_quartz_enabled", + "value": true + } + ], "result": { "item": "botania:quartztypedark", "data": 2, diff --git a/src/main/resources/assets/botania/recipes/rfgenerator.json b/src/main/resources/assets/botania/recipes/rfgenerator.json index 1a0126507..020994800 100644 --- a/src/main/resources/assets/botania/recipes/rfgenerator.json +++ b/src/main/resources/assets/botania/recipes/rfgenerator.json @@ -1,4 +1,10 @@ { + "conditions": [ + { + "type": "botania:fluxfield_enabled", + "value": true + } + ], "result": { "item": "botania:rfgenerator" },