forked from SleepyTrousers/EnderIO-1.5-1.12
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from GTNewHorizons/forestry_compat
Added forestry sapling support to farm station
- Loading branch information
Showing
3 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/crazypants/enderio/machine/farm/farmers/ForestryFarmer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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) { | ||
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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |