From 51497c98f74c03f83553cdf225a94aaf9ba7cc85 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Sat, 28 Mar 2015 02:01:16 -0500 Subject: [PATCH] Witchery Support BloodRose, Dandelion, Poppy, Shrub added to Flowers Acceptable (not spread) Belladonna, Mandrake, Mindrake, Snowbell, Wolfsbane, Wormwood, Garlic added to Crop Multifarm, seeds to squeezer. Saplings added to multifarm, fermenter. --- .../java/forestry/plugins/PluginManager.java | 3 +- .../java/forestry/plugins/PluginWitchery.java | 103 ++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/main/java/forestry/plugins/PluginWitchery.java diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 7c12b968e..f5435d234 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -95,7 +95,8 @@ public class PluginManager { MAGICALCROPS(new PluginMagicalCrops()), NATURA(new PluginNatura()), PLANTMEGAPACK(new PluginPlantMegaPack()), - UNDERGROUND_BIOMES(new PluginUndergroundBiomes()); + UNDERGROUND_BIOMES(new PluginUndergroundBiomes()), + WITCHERY(new PluginWitchery()); private final ForestryPlugin instance; private final boolean canBeDisabled; diff --git a/src/main/java/forestry/plugins/PluginWitchery.java b/src/main/java/forestry/plugins/PluginWitchery.java new file mode 100644 index 000000000..a08f05765 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginWitchery.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * 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 java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.apiculture.FlowerManager; +import forestry.api.farming.Farmables; +import forestry.api.recipes.RecipeManagers; +import forestry.core.GameMode; +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 = "Witchery", name = "Witchery", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.witchery.description") +public class PluginWitchery extends ForestryPlugin { + + private static final String Witch = "witchery"; + + @Override + public boolean isAvailable() { + return Proxies.common.isModLoaded(Witch); + } + + @Override + public String getFailMessage() { + return "Witchery not found"; + } + + @Override + protected void registerRecipes() { + + ImmutableList flowersAccept = ImmutableList.of( + "bloodrose", + "plantmine", + "glintweed" + ); + + Map cropSeed = new HashMap(); + //"artichoke", 4 water plant + cropSeed.put("belladonna", 4); + cropSeed.put("mandrake", 4); + cropSeed.put("mindrake", 4); + cropSeed.put("snowbell", 4); + cropSeed.put("wolfsbane", 7); + cropSeed.put("wormwood", 4); + + ImmutableList cropDirect = ImmutableList.of( + "garlic" //meta 5 + ); + int seedamount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + + Item saplingItem = GameRegistry.findItem(Witch, "witchsapling"); + ItemStack saplingStack = new ItemStack(saplingItem, 1, Defaults.WILDCARD); + RecipeUtil.injectLeveledRecipe(saplingStack, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + String saplingName = GameData.getItemRegistry().getNameForObject(saplingItem); + FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName)); + + for (String flowerAcceptName : flowersAccept) { + Block flowerBlock = GameRegistry.findBlock(Witch, flowerAcceptName); + if (flowerBlock != null) { + FlowerManager.flowerRegistry.registerAcceptableFlower(flowerBlock, FlowerManager.FlowerTypeVanilla); + } + } + for (String cropDirectName : cropDirect) { + Block cropDirectBlock = GameRegistry.findBlock(Witch, cropDirectName + "plant"); + ItemStack cropDirectStack = GameRegistry.findItemStack(Witch, cropDirectName, 1); + if (cropDirectStack != null && cropDirectBlock != null) { + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(cropDirectStack, cropDirectBlock, 5)); + } + } + for (Map.Entry cropSeedName : cropSeed.entrySet()) { + Block cropSeedBlock = GameRegistry.findBlock(Witch, cropSeedName.getKey()); + ItemStack cropSeedStack = GameRegistry.findItemStack(Witch, "seeds" + cropSeedName.getKey(), 1); + if (cropSeedStack != null && cropSeedBlock != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{cropSeedStack}, Fluids.SEEDOIL.getFluid(seedamount)); + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(cropSeedStack, cropSeedBlock, cropSeedName.getValue())); + } + + } + } +}