From fd41fb9ff75d3535c9ec8d5aa670e9877a2f6f98 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Fri, 6 Feb 2015 20:21:10 -0600 Subject: [PATCH] Add Support for Magical Crops Multifarm support (Wheat(Crop) tube) Fermenter/Squeezer support --- lang | 2 +- .../java/forestry/core/config/Config.java | 9 + .../forestry/plugins/PluginMagicalCrops.java | 184 ++++++++++++++++++ .../java/forestry/plugins/PluginManager.java | 1 + 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 src/main/java/forestry/plugins/PluginMagicalCrops.java diff --git a/lang b/lang index ae756ccd2..c0000f077 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit ae756ccd28d1a4728b0991038a2f4ac5260080be +Subproject commit c0000f0774692627d198bdd733a6c18679876a2e diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index bdeb94462..52c426c3d 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -81,6 +81,7 @@ public class Config { public static boolean squareFarms = false; public static boolean ExUtilEnderLily = true; + public static boolean MagicalCropsSupport = true; // Mail public static boolean mailAlertEnabled = true; @@ -114,6 +115,10 @@ public class Config { return ExUtilEnderLily; } + public static boolean isMagicalCropsSupportEnabled() { + return MagicalCropsSupport; + } + public static void load() { setDebugMode(); @@ -246,6 +251,10 @@ public class Config { supportEnderlily.comment = "set to false to disable multifarm support for ExtraUtilities Ender-lily seeds."; ExUtilEnderLily = Boolean.parseBoolean(supportEnderlily.value); + Property supportMagicalCrops = config.get("tweaks.farms.magicalcropssupport", CATEGORY_COMMON, true); + supportMagicalCrops.comment = "set to false to disable multifarm support for Magical Crops crops."; + MagicalCropsSupport = Boolean.parseBoolean(supportMagicalCrops.value); + property = config.get("structures.schemata.disabled", CATEGORY_COMMON, ""); property.comment = "add schemata keys to disable them. current keys: alveary3x3;farm3x3;farm3x4;farm3x5;farm4x4;farm5x5"; disabledStructures.addAll(Arrays.asList(parseStructureKeys(property.value))); diff --git a/src/main/java/forestry/plugins/PluginMagicalCrops.java b/src/main/java/forestry/plugins/PluginMagicalCrops.java new file mode 100644 index 000000000..9f6c7cd6f --- /dev/null +++ b/src/main/java/forestry/plugins/PluginMagicalCrops.java @@ -0,0 +1,184 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.farming.Farmables; +import forestry.api.recipes.RecipeManagers; +import forestry.core.GameMode; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; +import forestry.core.proxy.Proxies; +import forestry.core.utils.RecipeUtil; +import forestry.farming.logic.FarmableGenericCrop; + +@Plugin(pluginID = "MagicalCrops", name = "MagicalCrops", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.magicalcrops.description") +public class PluginMagicalCrops extends ForestryPlugin { + + private static final String MagCrop = "magicalcrops"; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(MagCrop); + } + + @Override + public String getFailMessage() { + return "Magical Crops not found"; + } + + @Override + protected void registerRecipes() { + + ImmutableList magicSeeds = ImmutableList.of( + "Essence", + "Coal", + "Dye", + "Redstone", + "Glowstone", + "Obsidian", + "Iron", + "Gold", + "Lapis", + "Ender", + "Nether", + "Experience", + "Blaze", + "Diamond", + "Emerald" + ); + + ImmutableList elementSeeds = ImmutableList.of( + "Air", + "Water", + "Earth", + "Fire" + ); + + ImmutableList modMagicSeeds = ImmutableList.of( + "Copper", + "Tin", + "Silver", + "Lead", + "Quartz", + "Sapphire", + "Ruby", + "Peridot", + "Aluminium", + "Force", + "Cobalt", + "Ardite", + "Nickel", + "Platinum", + "ThaumcraftShard", + "Uranium", + "Oil", + "Rubber", + "Vinteum", + "BlueTopaz", + "Chimerite", + "Moonstone", + "Sunstone", + "Iridium", + "Yellorite", + "Osmium", + "Manganese", + "Sulfur", + "Darkiron" + ); + + ImmutableList soulSeeds = ImmutableList.of( + "Cow", + "Creeper", + "Magma", + "Skeleton", + "Slime", + "Spider", + "Ghast", + "Wither" + ); + + ImmutableList potionSeeds = ImmutableList.of( + "Fire", + "Water", + "Strength", + "Regen", + "Night", + "Speed" + ); + + ImmutableList seeds = ImmutableList.of( + "Blackberry", + "Blueberry", + "Chili", + "Cucumber", + "Grape", + "Raspberry", + "Strawberry", + "Sweetcorn", + "Tomato", + "SugarCane" + ); + + int seedAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + + for (String magicSeedName : magicSeeds) { + addRecipes("_MagicSeeds", "_MagicCrop", magicSeedName, seedAmount); + } + + for (String elementSeedName : elementSeeds) { + addRecipes("_ElementSeeds", "_ElementCrop", elementSeedName, seedAmount); + } + + for (String modMagicSeedName : modMagicSeeds) { + addRecipes("_ModMagicSeeds", "_ModMagicCrop", modMagicSeedName, seedAmount); + } + + for (String soulSeedName : soulSeeds) { + addRecipes("_SoulSeeds", "_SoulCrop", soulSeedName, seedAmount); + } + + for (String potionSeedName : potionSeeds) { + addRecipes("_PotionSeeds", "_PotionCrop", potionSeedName, seedAmount); + } + + for (String seedName : seeds) { + addRecipes("_Seeds", "_Crop", seedName, seedAmount); + } + + Item cropProduce = GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce"); + if (cropProduce != null) { + int juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + ItemStack produce = new ItemStack(GameRegistry.findItem(MagCrop, MagCrop + "_CropProduce"), 1, Defaults.WILDCARD); + RecipeUtil.injectLeveledRecipe(produce, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{produce}, Fluids.JUICE.getFluid(juiceAmount)); + } + } + + private void addRecipes(String seedPrefix, String cropPrefix, String name, int fluidAmount) { + ItemStack seed = GameRegistry.findItemStack(MagCrop, MagCrop + seedPrefix + name, 1); + Block crop = GameRegistry.findBlock(MagCrop, MagCrop + cropPrefix + name); + if (seed != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{seed}, Fluids.SEEDOIL.getFluid(fluidAmount)); + } + if (seed != null && crop != null && Config.isMagicalCropsSupportEnabled()) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seed, crop, 7)); + } + } +} diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 9349416e5..54b2889b5 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -89,6 +89,7 @@ public class PluginManager { FARM_CRAFTORY(new PluginFarmCraftory()), INDUSTRIALCRAFT(new PluginIC2()), HARVESTCRAFT(new PluginHarvestCraft()), + MAGICALCROPS(new PluginMagicalCrops()), NATURA(new PluginNatura()), UNDERGROUND_BIOMES(new PluginUndergroundBiomes());