Skip to content
Browse files

Updated Forestry API. Removed obsolete integration for old farms, upd…

…ated fermentation values to new baseline.
  • Loading branch information...
1 parent 35c00eb commit b593cec5eacba7f02fcab6c852aa16a297f1ef4c @SirSengir committed Apr 9, 2013
View
80 common/extrabiomes/module/amica/forestry/CropProviderSapling.java
@@ -1,80 +0,0 @@
-/**
- * This work is licensed under the Creative Commons
- * Attribution-ShareAlike 3.0 Unported License. To view a copy of this
- * license, visit http://creativecommons.org/licenses/by-sa/3.0/.
- */
-
-package extrabiomes.module.amica.forestry;
-
-import java.util.ArrayList;
-
-import net.minecraft.block.Block;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
-import com.google.common.collect.Lists;
-
-import extrabiomes.helpers.ForestryModHelper;
-import forestry.api.cultivation.ICropEntity;
-import forestry.api.cultivation.ICropProvider;
-
-public class CropProviderSapling implements ICropProvider {
-
- @Override
- public boolean isGermling(ItemStack germling) {
- return ForestryModHelper.isGermling(germling);
- }
-
- @Override
- public boolean isCrop(World world, int x, int y, int z) {
- int id = world.getBlockId(x, y, z);
- return id == 0 || Block.blocksList[id] == null ? false : Block.blocksList[id]
- .isWood(world, x, y, z);
- }
-
- @Override
- public ItemStack[] getWindfall() {
- ArrayList windfall = Lists.newArrayList(ForestryModHelper.getSaplings());
-
- for (Object item : ForestryPlugin.loggerWindfall) {
- windfall.add(item);
- }
- return (ItemStack[]) windfall.toArray(new ItemStack[0]);
- }
-
- private static int forestrySoilBlockID = 0;
- private static int forestrySoilID() {
- if (forestrySoilBlockID == 0) {
- forestrySoilBlockID = ForestryPlugin.getBlock("soil").itemID;
- }
- return forestrySoilBlockID;
- }
-
- @Override
- public boolean doPlant(ItemStack germling, World world, int x,
- int y, int z)
- {
- int blockid = world.getBlockId(x, y, z);
-
- if (blockid != 0) {
- return false;
- }
- if (!isGermling(germling))
- return false;
-
- int below = world.getBlockId(x, y - 1, z);
- int meta = world.getBlockMetadata(x, y - 1, z);
- if (below != forestrySoilID() || (meta & 0x3) != 0) {
- return false;
- }
- world.setBlock(x, y, z,
- germling.itemID, germling.getItemDamage(), 3);
- return true;
- }
-
- @Override
- public ICropEntity getCrop(World world, int x, int y, int z) {
- return new CropSapling(world, x, y, z);
- }
-
-}
View
78 common/extrabiomes/module/amica/forestry/CropSapling.java
@@ -1,78 +0,0 @@
-/**
- * This work is licensed under the Creative Commons
- * Attribution-ShareAlike 3.0 Unported License. To view a copy of this
- * license, visit http://creativecommons.org/licenses/by-sa/3.0/.
- */
-
-package extrabiomes.module.amica.forestry;
-
-import java.util.ArrayList;
-
-import net.minecraft.block.Block;
-import net.minecraft.world.World;
-import forestry.api.cultivation.ICropEntity;
-
-public class CropSapling implements ICropEntity {
-
- private final World world;
- private final int x;
- private final int y;
- private final int z;
- private final int blockID;
- private final int metadata;
-
- public CropSapling(World world, int x, int y, int z) {
- this.world = world;
- this.x = x;
- this.y = y;
- this.z = z;
- blockID = world.getBlockId(x, y, z);
- metadata = world.getBlockMetadata(x, y, z);
- }
-
- @Override
- public ArrayList doHarvest() {
- final ArrayList harvest = Block.blocksList[blockID]
- .getBlockDropped(world, x, y, z, metadata, 0);
- world.setBlock(x, y, z, 0, 0, 3);
- return harvest;
- }
-
- @Override
- public int[] getNextPosition() {
- int[] next = null;
-
- int count = 1;
- int blockid = world.getBlockId(x, y + count, z);
- while (Block.blocksList[blockid] != null
- && Block.blocksList[blockid].isWood(world, x,
- y + count, z))
- {
- next = new int[] { x, y + count, z };
- count++;
- blockid = world.getBlockId(x, y + count, z);
- }
-
- if (next != null) return next;
- count = -1;
- blockid = world.getBlockId(x, y + count, z);
- while (Block.blocksList[blockid] != null
- && Block.blocksList[blockid].isWood(world, x,
- y + count, z))
- {
- next = new int[] { x, y + count, z };
- count--;
- blockid = world.getBlockId(x, y + count, z);
- }
-
- return next;
- }
-
- @Override
- public boolean isHarvestable() {
- final int blockId = world.getBlockId(x, y, z);
- return Block.blocksList[blockId] != null
- && Block.blocksList[blockId].isWood(world, x, y, z);
- }
-
-}
View
20 common/extrabiomes/module/amica/forestry/ForestryPlugin.java
@@ -38,13 +38,10 @@
private Object carpenterManager;
private static boolean enabled = true;
- private ArrayList arborealCrops;
private ArrayList plainFlowers;
private ArrayList leafBlockIds;
private ArrayList[] backpackItems;
- public static ArrayList loggerWindfall;
-
/**
* public void addRecipe(int packagingTime, LiquidStack liquid,
* ItemStack box, ItemStack product, Object materials[]);
@@ -71,6 +68,8 @@
private static final int FORESTER = 2;
+ private static final int BIOMASS_SAPLINGS = 200;
+
static ItemStack getBlock(String name) {
try {
return (ItemStack) getForestryBlock.get().invoke(null, name);
@@ -98,11 +97,11 @@ private void addBasicFlowers() {
}
private void addFermenterRecipeSapling(ItemStack resource) throws Exception {
- fermenterAddRecipe.get().invoke(fermenterManager, resource, 800, 1.0f,
+ fermenterAddRecipe.get().invoke(fermenterManager, resource, BIOMASS_SAPLINGS, 1.0f,
getLiquidStack("liquidBiomass"), new LiquidStack(Block.waterStill.blockID, 1, 0));
- fermenterAddRecipe.get().invoke(fermenterManager, resource, 800, 1.5f,
+ fermenterAddRecipe.get().invoke(fermenterManager, resource, BIOMASS_SAPLINGS, 1.5f,
getLiquidStack("liquidBiomass"), getLiquidStack("liquidJuice"));
- fermenterAddRecipe.get().invoke(fermenterManager, resource, 800, 1.5f,
+ fermenterAddRecipe.get().invoke(fermenterManager, resource, BIOMASS_SAPLINGS, 1.5f,
getLiquidStack("liquidBiomass"), getLiquidStack("liquidHoney"));
}
@@ -130,7 +129,6 @@ private void addSaplings() {
TreeSoilRegistry.addValidSoil(Block.blocksList[soil.get().itemID]);
BlockCustomSapling.setForestrySoilID(soil.get().itemID);
}
- arborealCrops.add(new CropProviderSapling());
for(ItemStack sapling : ForestryModHelper.getSaplings())
FMLInterModComms.sendMessage("Forestry", "add-farmable-sapling", String.format("farmArboreal@%s.%s", sapling.itemID, sapling.getItemDamage()));
@@ -173,14 +171,6 @@ public void preInit(PluginEvent.Pre event) {
fld = cls.getField("carpenterManager");
carpenterManager = fld.get(null);
- cls = Class.forName("forestry.api.core.ForestryAPI");
- fld = cls.getField("loggerWindfall");
- loggerWindfall = (ArrayList) fld.get(null);
-
- cls = Class.forName("forestry.api.cultivation.CropProviders");
- fld = cls.getField("arborealCrops");
- arborealCrops = (ArrayList) fld.get(null);
-
cls = Class.forName("forestry.api.apiculture.FlowerManager");
fld = cls.getField("plainFlowers");
plainFlowers = (ArrayList) fld.get(null);

0 comments on commit b593cec

Please sign in to comment.
Something went wrong with that request. Please try again.