Permalink
Browse files

Updated Forestry integration for 1.5.1.

  • Loading branch information...
1 parent e1ecd47 commit df21f4a27c79dab181747a193c000bda84b73b5c @SirSengir committed Apr 9, 2013
@@ -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);
- }
-
-}
@@ -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);
- }
-
-}
@@ -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 = 250;
+
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);
@@ -1,25 +0,0 @@
-package forestry.api.cultivation;
-
-import java.util.ArrayList;
-
-import net.minecraft.item.ItemStack;
-
-public interface ICropEntity {
-
- /**
- * @return True if the crop is ready for harvest
- */
- public boolean isHarvestable();
-
- /**
- * @return Integer array of three designating the coordinates to check for a crop after this one. Useful to chop down whole trees. Return null to skip this
- * function.
- */
- public int[] getNextPosition();
-
- /**
- * @return Itemstacks gathered from the harvest. Also responsible for removing the harvested crop from the world.
- */
- public ArrayList<ItemStack> doHarvest();
-
-}
@@ -1,54 +0,0 @@
-package forestry.api.cultivation;
-
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
-public interface ICropProvider {
-
- /**
- * @param germling
- * @return True if the passed itemstack is a valid germling for use in planting.
- */
- public boolean isGermling(ItemStack germling);
-
- /**
- * @param world
- * @param x
- * @param y
- * @param z
- * @return True if the block at the passed location is a valid crop (mature or immature). Includes saplings!
- */
- public boolean isCrop(World world, int x, int y, int z);
-
- /**
- * Called once to configure possible windfall created by harvested crops managed by this provider.
- *
- * @return Array of item stacks representing possible windfall.
- */
- public ItemStack[] getWindfall();
-
- /**
- * Plant a crop in the world with the germling given. Planter will have called isGermling beforehand.
- *
- * @param germling
- * ItemStack representing the germling available. Stack is decreased by the planter, not by the provider.
- * @param world
- * @param x
- * @param y
- * @param z
- * @return True if planting is successfull, false otherwise.
- */
- public boolean doPlant(ItemStack germling, World world, int x, int y, int z);
-
- /**
- * Returns the crop at the given location. Planter will have called isCrop beforehand.
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @return
- */
- public ICropEntity getCrop(World world, int x, int y, int z);
-
-}

0 comments on commit df21f4a

Please sign in to comment.