Files
ForestryMC/src/main/java/forestry/plugins/PluginNatura.java
T

256 lines
11 KiB
Java
Raw Normal View History

2014-05-02 21:31:20 +02:00
/*******************************************************************************
2014-08-07 08:29:25 +02:00
* 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
2014-08-07 02:56:58 -07:00
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
2014-08-07 08:29:25 +02:00
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
2014-05-02 21:31:20 +02:00
******************************************************************************/
package forestry.plugins;
import java.util.ArrayList;
2015-01-19 01:59:03 -06:00
import java.util.List;
import net.minecraft.block.Block;
2015-01-19 01:59:03 -06:00
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
2014-05-02 21:31:20 +02:00
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.registry.GameData;
2014-05-02 21:31:20 +02:00
import cpw.mods.fml.common.registry.GameRegistry;
2015-01-19 01:59:03 -06:00
import forestry.api.farming.Farmables;
2014-05-02 21:31:20 +02:00
import forestry.api.recipes.RecipeManagers;
2015-01-19 01:59:03 -06:00
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
2014-05-02 21:31:20 +02:00
import forestry.core.GameMode;
import forestry.core.config.Defaults;
2015-01-19 01:59:03 -06:00
import forestry.core.config.ForestryItem;
2014-12-13 18:58:49 -08:00
import forestry.core.fluids.Fluids;
2014-05-02 21:31:20 +02:00
import forestry.core.proxy.Proxies;
import forestry.core.utils.RecipeUtil;
2015-01-19 01:59:03 -06:00
import forestry.farming.logic.FarmableGenericCrop;
2014-05-02 21:31:20 +02:00
2014-09-27 12:46:54 -07:00
@Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description")
public class PluginNatura extends ForestryPlugin {
2014-05-02 21:31:20 +02:00
private static final String NATURA = "Natura";
2014-05-02 21:31:20 +02:00
public static Block logNatura;
public static Block logWillow;
2014-05-02 21:31:20 +02:00
public static Block leavesNatura;
public static Block saplingNatura;
2014-09-09 03:29:47 -07:00
public static Block saplingNaturaRare;
2015-01-19 01:59:03 -06:00
public static ItemStack berryBlight;
public static ItemStack berryDusk;
public static ItemStack berrySky;
public static ItemStack berrySting;
public static ItemStack berryRasp;
public static ItemStack berryBlue;
public static ItemStack berryBlack;
public static ItemStack berryMalo;
public static ItemStack itemBarley;
2014-05-02 21:31:20 +02:00
@Override
public boolean isAvailable() {
return Proxies.common.isModLoaded(NATURA);
}
@Override
public String getFailMessage() {
return "Natura not found";
}
2014-05-02 21:31:20 +02:00
@Override
public void doInit() {
super.doInit();
logNatura = GameRegistry.findBlock(NATURA, "tree");
logWillow = GameRegistry.findBlock(NATURA, "willow");
leavesNatura = GameRegistry.findBlock(NATURA, "floraleaves");
saplingNatura = GameRegistry.findBlock(NATURA, "florasapling");
saplingNaturaRare = GameRegistry.findBlock(NATURA, "Rare Sapling");
2014-09-09 03:29:47 -07:00
ArrayList<String> saplingItemKeys = new ArrayList<String>();
if (saplingNatura != null) {
2014-09-09 03:29:47 -07:00
saplingItemKeys.add("florasapling");
}
if (saplingNaturaRare != null) {
saplingItemKeys.add("Rare Sapling");
}
2014-09-09 03:29:47 -07:00
for (String key : saplingItemKeys) {
Item saplingItem = GameRegistry.findItem(NATURA, key);
ItemStack saplingWild = new ItemStack(saplingItem, 1, Defaults.WILDCARD);
RecipeUtil.injectLeveledRecipe(saplingWild, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
2014-09-09 03:29:47 -07:00
String saplingName = GameData.getItemRegistry().getNameForObject(saplingItem);
FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
}
2015-01-19 01:59:03 -06:00
berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1);
berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1);
berrySky = GameRegistry.findItemStack(NATURA, "berrySky", 1);
berrySting = GameRegistry.findItemStack(NATURA, "berrySting", 1);
berryRasp = GameRegistry.findItemStack(NATURA, "berryRasp", 1);
berryBlue = GameRegistry.findItemStack(NATURA, "berryBlue", 1);
berryBlack = GameRegistry.findItemStack(NATURA, "berryBlack", 1);
berryMalo = GameRegistry.findItemStack(NATURA, "berryMalo", 1);
itemBarley = GameRegistry.findItemStack(NATURA, "barleyFood", 1);
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
if (berryBlight != null) {
crateRegistry.registerCrate(berryBlight, "cratedNaturaBerryBlight");
}
if (berryDusk != null) {
crateRegistry.registerCrate(berryDusk, "cratedNaturaBerryDusk");
}
if (berrySky != null) {
crateRegistry.registerCrate(berrySky, "cratedNaturaBerrySky");
}
if (berrySting != null) {
crateRegistry.registerCrate(berrySting, "cratedNaturaBerrySting");
}
if (berryRasp != null) {
crateRegistry.registerCrate(berryRasp, "cratedNaturaBerryRasp");
}
if (berryBlue != null) {
crateRegistry.registerCrate(berryBlue, "cratedNaturaBerryBlue");
}
if (berryBlack != null) {
crateRegistry.registerCrate(berryBlack, "cratedNaturaBerryBlack");
}
if (berryMalo != null) {
crateRegistry.registerCrate(berryMalo, "cratedNaturaBerryMalo");
}
if (itemBarley != null) {
crateRegistry.registerCrate(itemBarley, "cratedNaturaBarley");
}
if (saplingNatura != null) {
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 0), "cratedNaturaSaplingRedwood");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 1), "cratedNaturaSaplingEucalyptus");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 2), "cratedNaturaSaplingHopseed");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 3), "cratedNaturaSaplingSakura");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 4), "cratedNaturaSaplingGhostwood");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 5), "cratedNaturaSaplingBlood");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 6), "cratedNaturaSaplingDarkwood");
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 7), "cratedNaturaSaplingFusewood");
}
if (saplingNaturaRare != null) {
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 0), "cratedNaturaSaplingMaple");
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 1), "cratedNaturaSaplingSilverbell");
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 2), "cratedNaturaSaplingPurpleheart");
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 3), "cratedNaturaSaplingTiger");
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 4), "cratedNaturaSaplingWillow");
}
Item potashApple = GameRegistry.findItem(NATURA, "Natura.netherfood");
if (potashApple != null) {
crateRegistry.registerCrate(new ItemStack(potashApple, 1, 0), "cratedNaturaPotashApple");
}
Item glowShroom = GameRegistry.findItem(NATURA, "Glowshroom");
if (glowShroom != null) {
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 0), "cratedNaturaGreenGlowshroom");
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 1), "cratedNaturaPurpleGlowshroom");
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 2), "cratedNaturaBlueGlowshroom");
}
if (logNatura != null) {
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 0), "cratedNaturaLogEucalyptus");
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 1), "cratedNaturaLogSakura");
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 2), "cratedNaturaLogGhostwood");
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 3), "cratedNaturaLogHopseed");
crateRegistry.registerCrate(new ItemStack(logWillow, 1, 0), "cratedNaturaLogWillow");
}
Item bloodWood = GameRegistry.findItem(NATURA, "bloodwood");
if (bloodWood != null) {
crateRegistry.registerCrate(new ItemStack(bloodWood, 1, 0), "cratedNaturaLogBloodwood");
}
Item darkTree = GameRegistry.findItem(NATURA, "Dark Tree");
if (darkTree != null) {
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 0), "cratedNaturaLogDarkwood");
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 1), "cratedNaturaLogFusewood");
}
Item heatSand = GameRegistry.findItem(NATURA, "heatsand");
if (heatSand != null) {
crateRegistry.registerCrate(new ItemStack(heatSand, 1, 0), "cratedNaturaBlockHeatsand");
}
Item taintedSoil = GameRegistry.findItem(NATURA, "soil.tainted");
if (taintedSoil != null) {
crateRegistry.registerCrate(new ItemStack(taintedSoil, 1, 0), "cratedNaturaBlockTainted");
}
2014-05-02 21:31:20 +02:00
}
2014-05-02 21:31:20 +02:00
@Override
protected void registerRecipes() {
ItemStack seedBarley = GameRegistry.findItemStack(NATURA, "seedBarley", 1);
ItemStack seedCotton = GameRegistry.findItemStack(NATURA, "seedCotton", 1);
2014-05-02 21:31:20 +02:00
ArrayList<ItemStack> seedList = new ArrayList<ItemStack>();
if (seedBarley != null) {
2014-05-02 21:31:20 +02:00
seedList.add(seedBarley);
}
if (seedCotton != null) {
2014-05-02 21:31:20 +02:00
seedList.add(seedCotton);
}
2014-05-02 21:31:20 +02:00
int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed");
for (ItemStack aSeedList : seedList) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.getFluid(amount));
}
2015-01-19 01:59:03 -06:00
Block cropBlock = GameRegistry.findBlock(NATURA, "N Crops");
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedBarley, cropBlock, 3));
2015-01-30 03:12:58 -06:00
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedCotton, cropBlock, 8));
2015-01-19 01:59:03 -06:00
List<ItemStack> berries = new ArrayList<ItemStack>();
if (berryBlight != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryBlight);
}
if (berryDusk != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryDusk);
}
if (berrySky != null) {
2014-05-02 21:31:20 +02:00
berries.add(berrySky);
}
if (berrySting != null) {
2014-05-02 21:31:20 +02:00
berries.add(berrySting);
}
if (berryRasp != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryRasp);
}
if (berryBlue != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryBlue);
}
if (berryBlack != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryBlack);
}
if (berryMalo != null) {
2014-05-02 21:31:20 +02:00
berries.add(berryMalo);
}
2015-01-19 01:59:03 -06:00
amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 2;
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(GameRegistry.findItem(NATURA, "Natura.netherfood"), 1, 0)}, Fluids.JUICE.getFluid(amount), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"));
2014-05-02 21:31:20 +02:00
amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25;
2015-01-19 01:59:03 -06:00
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
for (ItemStack berry : berries) {
RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.getFluid(amount));
}
2015-01-19 01:59:03 -06:00
if (itemBarley != null) {
RecipeUtil.injectLeveledRecipe(itemBarley, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
}
2015-01-19 01:59:03 -06:00
if (GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat").stackSize > 0) {
Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat"), " X ", "X#X", " X ", '#', Blocks.dirt, 'X', itemBarley);
}
2014-05-02 21:31:20 +02:00
}
}