diff --git a/gradle.properties b/gradle.properties index 9f0e9f3d59..407377cbfb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ minecraft_version=1.7.10 forge_version=10.13.4.1614-1.7.10 forgeDep_version=10.13.4.1614 -mod_version=2.3.1.13_beta +mod_version=2.3.1.14_beta #Comment out this line to get rid of the appendix #mod_appendix=beta diff --git a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java index 89b10b7fd2..a5c2663d99 100644 --- a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java +++ b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java @@ -24,6 +24,7 @@ import crazypants.enderio.machine.farm.farmers.RubberTreeFarmerIC2; import crazypants.enderio.machine.farm.farmers.StemFarmer; import crazypants.enderio.machine.farm.farmers.TreeFarmer; +import crazypants.enderio.machine.farm.farmers.ForestryFarmer; public final class FarmersRegistry { @@ -34,13 +35,10 @@ public static void addFarmers() { addExtraUtilities(); addNatura(); addTiC(); - addStillHungry(); addIC2(); - addMFR(); addThaumcraft(); addFlowers(); - addGrowableOres(); - addImmersiveEngineering(); + ForestryFarmer.init(); FarmersCommune.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds))); FarmersCommune.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus))); @@ -178,16 +176,6 @@ private static void addThaumcraft() } } - private static void addMFR() { - String mod = "MineFactoryReloaded"; - String blockName = "rubberwood.sapling"; - Block saplingBlock = GameRegistry.findBlock(mod, blockName); - if(saplingBlock != null) { - FarmersCommune.joinCommune(new TreeFarmer(saplingBlock, GameRegistry.findBlock(mod, "rubberwood.log"))); - } - - } - private static void addIC2() { RubberTreeFarmerIC2 rtf = new RubberTreeFarmerIC2(); if(rtf.isValid()) { @@ -195,11 +183,6 @@ private static void addIC2() { } } - private static void addStillHungry() { - String mod = "stillhungry"; - addPickable(mod, "grapeBlock", "StillHungry_grapeSeed"); - } - private static void addExtraUtilities() { String mod = "ExtraUtilities"; String name = "plant/ender_lilly"; @@ -219,36 +202,6 @@ private static void addFlowers() { GameRegistry.findBlock("Botany", "flower"), GameRegistry.findBlock("Botania", "flower") ) ); } - - @SuppressWarnings("unchecked") - private static void addGrowableOres() { - String mod = "B0bGrowsOre"; - if (!Loader.isModLoaded(mod)) { - return; - } - Pattern[] growableOres = { Pattern.compile("(.+)Reed"), Pattern.compile("oreGrowable(.+)") }; - - Iterator blockIter = Block.blockRegistry.iterator(); - while (blockIter.hasNext()) { - Block block = blockIter.next(); - String name = Block.blockRegistry.getNameForObject(block); - if (name != null && name.startsWith(mod)) { - for (Pattern blockPattern : growableOres) { - if (blockPattern.matcher(name).find()) { - FarmersCommune.joinCommune(new StemFarmer(block, new ItemStack(block))); - } - } - } - } - } - - private static void addImmersiveEngineering() { - Block hemp = GameRegistry.findBlock("ImmersiveEngineering", "hemp"); - Item hempSeed = GameRegistry.findItem("ImmersiveEngineering", "hemp"); - if (hemp != null && hempSeed != null) { - FarmersCommune.joinCommune(new StemFarmer(hemp, new ItemStack(hempSeed))); - } - } private FarmersRegistry() { } diff --git a/src/main/java/crazypants/enderio/machine/farm/farmers/ForestryFarmer.java b/src/main/java/crazypants/enderio/machine/farm/farmers/ForestryFarmer.java new file mode 100644 index 0000000000..6fb6b7f5ea --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/farm/farmers/ForestryFarmer.java @@ -0,0 +1,69 @@ +package crazypants.enderio.machine.farm.farmers; + +import com.enderio.core.common.util.BlockCoord; +import cpw.mods.fml.common.registry.GameRegistry; +import crazypants.enderio.Log; +import crazypants.enderio.machine.farm.TileFarmStation; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeRoot; +import forestry.api.genetics.AlleleManager; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class ForestryFarmer implements IFarmerJoe { + private ITreeRoot root; + private Item forestrySapling; + + private ForestryFarmer(ITreeRoot root, Item forestrySapling) { + this.root = root; + this.forestrySapling = forestrySapling; + } + + public static void init() { + ITreeRoot root = (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); + Item forestrySapling = GameRegistry.findItem("Forestry", "sapling"); + if (root != null && forestrySapling != null) { + FarmersCommune.joinCommune(new ForestryFarmer(root, forestrySapling)); + Log.info("ForestryFarmer engaged."); + } else { + Log.info("ForestryFarmer borked."); + } + } + + @Override + public boolean canPlant(ItemStack stack) { + Log.debug("CAN PLANT - Forestry"); + return stack != null && stack.getItem() == forestrySapling && root.getType(stack) == EnumGermlingType.SAPLING; + } + + @Override + public boolean prepareBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) { + ItemStack sapling = farm.getSeedTypeInSuppliesFor(bc); + ITree tree = root.getMember(sapling); + if (tree != null && tree.canStay(farm.getWorldObj(), bc.x, bc.y, bc.z)) { + farm.takeSeedFromSupplies(sapling, bc, false); + root.plantSapling(farm.getWorldObj(), tree, farm.getFakePlayer().getGameProfile(), bc.x, bc.y, bc.z); + return true; + } + return false; + + } + + @Override + public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) { + return false; + } + + + @Override + public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) { + return null; + } + + + + + +}