HarvestCraft Integration part 1

Multifarm support for all plant based crops. Plants/Tree Fruit
ferment-able/squeezable (Add Fluid Vegetable Juice) Seeds squeezable into Seed
Oil Honey squeezable into Honey Beeswax can be made into wax capsules Grain
crops can be used for Compost

HarvestCraft Integration part 2
Add Basic Orchard Tube (Apple Infused)
Supports all trees, bark and fruit-ish
All crops should now be supported
Vegetables produce Vegetable juice and go into the Vegetables tube
Everything else ground based goes to the Wheat(Crop) tube

Lastminute typos are the best.

mezz - Have regular orchard handle HarvestCraft too
This commit is contained in:
Nirek-K authored and mezz committed 2015-02-01 23:43:48 -08:00
1 parent c576f745fb
commit f6b92ad6ac
8 files changed
+522 -25

No files matched your search

@@ -446,6 +446,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
setErrorState(EnumErrorCode.NOFERTILIZER);
} else if (!hasLiquid) {
setErrorState(EnumErrorCode.NOLIQUID);
} else {
setErrorState(EnumErrorCode.OK);
}
return didWork;
@@ -0,0 +1,50 @@
/*******************************************************************************
* 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
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.farming.logic;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.Collection;
public class CropBasicFruit extends Crop {
protected final Block block;
protected final int meta;
public CropBasicFruit(World world, Block block, int meta, Vect position) {
super(world, position);
this.block = block;
this.meta = meta;
}
@Override
protected boolean isCrop(Vect pos) {
return getBlock(pos) == block && getBlockMeta(pos) == meta;
}
@Override
protected Collection<ItemStack> harvestBlock(Vect pos) {
Collection<ItemStack> harvested = block.getDrops(world, pos.x, pos.y, pos.z, meta, 0);
Proxies.common.addBlockDestroyEffects(world, pos.x, pos.y, pos.z, block, 0);
world.setBlock(pos.x, pos.y, pos.z, block, 0, Defaults.FLAG_BLOCK_SYNCH);
return harvested;
}
@Override
public String toString() {
return String.format("CropBasicFruit [ position: [ %s ]; block: %s; meta: %s ]", position.toString(), block.getUnlocalizedName(), meta);
}
}
@@ -14,10 +14,10 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
@@ -28,8 +28,10 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.api.genetics.IFruitBearer;
import forestry.core.config.ForestryItem;
import forestry.core.vect.Vect;
@@ -37,8 +39,11 @@ import forestry.core.vect.VectUtil;
public class FarmLogicOrchard extends FarmLogic {
private final Collection<IFarmable> farmables;
public FarmLogicOrchard(IFarmHousing housing) {
super(housing);
this.farmables = Farmables.farmables.get("farmOrchard");
}
@Override
@@ -97,8 +102,6 @@ public class FarmLogicOrchard extends FarmLogic {
lastExtent = 0;
}
// Proxies.log.finest("Logic %s is searching in direction %s at %s/%s/%s with extension %s.", getClass(), direction, x, y, z, lastExtent);
Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
Collection<ICrop> crops = getHarvestBlocks(position);
lastExtent++;
@@ -115,14 +118,12 @@ public class FarmLogicOrchard extends FarmLogic {
World world = getWorld();
// Determine what type we want to harvest.
IFruitBearer bearer = getFruitBlock(position);
Block block = VectUtil.getBlock(world, position);
if ((!block.isWood(getWorld(), position.x, position.y, position.z)) && bearer == null) {
if (!VectUtil.isWoodBlock(world, position) && !isFruitBearer(world, position)) {
return crops;
}
ArrayList<Vect> candidates = processHarvestBlock(crops, seen, position, position);
ArrayList<Vect> temp = new ArrayList<Vect>();
List<Vect> candidates = processHarvestBlock(crops, seen, position, position);
List<Vect> temp = new ArrayList<Vect>();
while (!candidates.isEmpty() && crops.size() < 20) {
for (Vect candidate : candidates) {
temp.addAll(processHarvestBlock(crops, seen, position, candidate));
@@ -131,15 +132,14 @@ public class FarmLogicOrchard extends FarmLogic {
candidates.addAll(temp);
temp.clear();
}
// Proxies.log.finest("Logic at %s/%s/%s has seen %s blocks.", position.x, position.y, position.z, seen.size());
return crops;
}
private ArrayList<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
private List<Vect> processHarvestBlock(Stack<ICrop> crops, Set<Vect> seen, Vect start, Vect position) {
World world = getWorld();
ArrayList<Vect> candidates = new ArrayList<Vect>();
List<Vect> candidates = new ArrayList<Vect>();
// Get additional candidates to return
for (int i = -1; i < 2; i++) {
@@ -161,16 +161,17 @@ public class FarmLogicOrchard extends FarmLogic {
continue;
}
IFruitBearer bearer = getFruitBlock(candidate);
if (bearer != null && bearer.hasFruit()) {
if (bearer.getRipeness() >= 0.9f) {
crops.push(new CropFruit(world, candidate, bearer.getFruitFamily()));
if (VectUtil.isWoodBlock(world, candidate)) {
candidates.add(candidate);
seen.add(candidate);
} else if (isFruitBearer(world, candidate)){
candidates.add(candidate);
seen.add(candidate);
ICrop crop = getCrop(world, candidate);
if (crop != null) {
crops.push(crop);
}
candidates.add(candidate);
seen.add(candidate);
} else if (VectUtil.isWoodBlock(world, candidate)) {
candidates.add(candidate);
seen.add(candidate);
}
}
}
@@ -179,13 +180,48 @@ public class FarmLogicOrchard extends FarmLogic {
return candidates;
}
private IFruitBearer getFruitBlock(Vect position) {
TileEntity tile = getWorld().getTileEntity(position.x, position.y, position.z);
if (!(tile instanceof IFruitBearer)) {
private boolean isFruitBearer(World world, Vect position) {
if (VectUtil.isAirBlock(world, position)) {
return false;
}
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
if (tile instanceof IFruitBearer) {
return true;
}
for (IFarmable farmable : farmables) {
if (farmable.isSaplingAt(world, position.x, position.y, position.z)) {
return true;
}
}
return false;
}
private ICrop getCrop(World world, Vect position) {
if (VectUtil.isAirBlock(world, position)) {
return null;
}
return (IFruitBearer) tile;
TileEntity tile = world.getTileEntity(position.x, position.y, position.z);
if (tile instanceof IFruitBearer) {
IFruitBearer fruitBearer = (IFruitBearer) tile;
if (fruitBearer.hasFruit() && fruitBearer.getRipeness() >= 0.9f) {
return new CropFruit(world, position, fruitBearer.getFruitFamily());
}
} else {
for (IFarmable seed : farmables) {
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
if (crop != null) {
return crop;
}
}
}
return null;
}
}
@@ -0,0 +1,65 @@
/*******************************************************************************
* 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
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.core.config.Defaults;
import forestry.core.utils.StackUtils;
import forestry.core.vect.Vect;
public class FarmableBasicFruit implements IFarmable {
private final Block block;
private final int matureMeta;
public FarmableBasicFruit(Block block, int matureMeta) {
this.block = block;
this.matureMeta = matureMeta;
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
}
@Override
public ICrop getCropAt(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != block) {
return null;
}
if (world.getBlockMetadata(x, y, z) != matureMeta) {
return null;
}
return new CropBasicFruit(world, block, matureMeta, new Vect(x, y, z));
}
@Override
public boolean isGermling(ItemStack itemstack) {
return StackUtils.equals(block, itemstack);
}
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
return world.setBlock(x, y, z, block, 0, Defaults.FLAG_BLOCK_SYNCH);
}
@Override
public boolean isWindfall(ItemStack itemstack) {
return false;
}
}
@@ -96,6 +96,8 @@ public class PluginFarming extends ForestryPlugin {
Farmables.farmables.get("farmArboreal").add(new FarmableVanillaSapling());
Farmables.farmables.get("farmArboreal").add(new FarmableGE());
Farmables.farmables.put("farmOrchard", new ArrayList<IFarmable>());
Farmables.farmables.put("farmShroom", new ArrayList<IFarmable>());
Farmables.farmables.get("farmShroom").add(new FarmableVanillaShroom(Blocks.brown_mushroom, 0));
Farmables.farmables.get("farmShroom").add(new FarmableVanillaShroom(Blocks.red_mushroom, 0));
@@ -0,0 +1,341 @@
/*******************************************************************************
* 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
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.plugins;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.farming.Farmables;
import forestry.api.recipes.RecipeManagers;
import forestry.core.GameMode;
import forestry.core.config.Defaults;
import forestry.core.fluids.Fluids;
import forestry.core.proxy.Proxies;
import forestry.core.utils.RecipeUtil;
import forestry.farming.logic.FarmableBasicFruit;
import forestry.farming.logic.FarmableGenericCrop;
@Plugin(pluginID = "HarvestCraft", name = "HarvestCraft", author = "Nirek", url = Defaults.URL, unlocalizedDescription = "for.plugin.harvestcraft.description")
public class PluginHarvestCraft extends ForestryPlugin {
private static final String HC = "harvestcraft";
@Override
public boolean isAvailable() {
return Proxies.common.isModLoaded(HC);
}
@Override
public String getFailMessage() {
return "HarvestCraft not found";
}
@Override
protected void registerRecipes() {
ImmutableList<String> berries = ImmutableList.of(
"cranberry",
"blackberry",
"blueberry",
"raspberry",
"strawberry"
);
ImmutableList<String> fruits = ImmutableList.of(
"pineapple",
"cactusfruit",
"cantaloupe",
"grape",
"kiwi",
"chilipepper"
);
ImmutableList<String> treeFruits = ImmutableList.of(
"banana",
"dragonfruit",
"lemon",
"lime",
"mango",
"orange",
"papaya",
"peach",
"pear",
"plum",
"pomegranate",
"starfruit",
"apricot",
"date",
"fig",
"grapefruit",
"persimmon",
"avocado",
"coconut",
"durian"
);
ImmutableList<String> trees = ImmutableList.of(
"nutmeg",
"olive",
"peppercorn"
);
ImmutableList<String> treesSpecial = ImmutableList.of(
"cinnamon",
"maple",
"paperbark",
"vanillabean",
"apple" // to prevent apples from getting double registered
);
ImmutableList<String> herbs = ImmutableList.of(
"garlic"
);
ImmutableList<String> spices = ImmutableList.of(
"ginger",
"spiceleaf",
"mustardseed"
);
ImmutableList<String> vegetables = ImmutableList.of(
"asparagus",
"bean",
"beet",
"broccoli",
"cauliflower",
"celery",
"leek",
"lettuce",
"onion",
"parsnip",
"radish",
"rutabaga",
"scallion",
"soybean",
"sweetpotato",
"turnip",
"whitemushroom",
"artichoke",
"bellpepper",
"brusselsprout",
"cabbage",
"corn",
"cucumber",
"eggplant",
"okra",
"peas",
"rhubarb",
"seaweed",
"tomato",
"wintersquash",
"zucchini",
"bambooshoot"
);
ImmutableList<String> grains = ImmutableList.of(
"barley",
"oats",
"rye"
);
ImmutableList<String> cropNuts = ImmutableList.of(
"peanut"
);
ImmutableList<String> nuts = ImmutableList.of(
"walnut",
"almond",
"cashew",
"chestnut",
"pecan",
"pistachio",
"cherry" //Cherries in forestry make seed oil
);
ImmutableList.Builder<String> genericCropsBuilder = ImmutableList.builder();
genericCropsBuilder.add(
"cotton",
"rice",
"tea",
"coffee",
"candleberry"
);
genericCropsBuilder.addAll(herbs);
genericCropsBuilder.addAll(spices);
ImmutableList<String> genericCrops = genericCropsBuilder.build();
ImmutableList.Builder<String> plants = ImmutableList.builder();
int juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25;
int seedamount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed");
ItemStack wheatamount = GameMode.getGameMode().getStackSetting("recipe.output.compost.wheat");
juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice.
for (String berryName : berries) {
ItemStack berry = GameRegistry.findItemStack(HC, berryName + "Item", 1);
ItemStack berrySeed = GameRegistry.findItemStack(HC, berryName + "seedItem", 1);
Block berryBlock = GameRegistry.findBlock(HC, "pam" + berryName + "Crop");
if (berry != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{berry}, Fluids.JUICE.getFluid(juiceAmount));
}
if (berrySeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{berrySeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (berrySeed != null && berryBlock != null) {
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(berrySeed, berryBlock, 7));
}
plants.add(berryName);
}
juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple");
for (String fruitName : fruits) {
ItemStack fruit = GameRegistry.findItemStack(HC, fruitName + "Item", 1);
ItemStack fruitSeed = GameRegistry.findItemStack(HC, fruitName + "seedItem", 1);
Block fruitBlock = GameRegistry.findBlock(HC, "pam" + fruitName + "Crop");
if (fruit != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{fruit}, Fluids.JUICE.getFluid(juiceAmount));
}
if (fruitSeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{fruitSeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (fruitSeed != null && fruitBlock != null) {
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(fruitSeed, fruitBlock, 7));
}
plants.add(fruitName);
}
juiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 2; // vegetables produce less juice
juiceAmount = Math.max(juiceAmount, 1); // Produce at least 1 mb of juice.
for (String vegetableName : vegetables) {
ItemStack vegetable = GameRegistry.findItemStack(HC, vegetableName + "Item", 1);
ItemStack vegetableSeed = GameRegistry.findItemStack(HC, vegetableName + "seedItem", 1);
Block vegetableBlock = GameRegistry.findBlock(HC, "pam" + vegetableName + "Crop");
if (vegetable != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{vegetable}, Fluids.JUICE.getFluid(juiceAmount));
}
if (vegetableSeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{vegetableSeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (vegetableSeed != null && vegetableBlock != null) {
Farmables.farmables.get("farmVegetables").add(new FarmableGenericCrop(vegetableSeed, vegetableBlock, 7));
}
plants.add(vegetableName);
}
for (String grainName : grains) {
ItemStack grain = GameRegistry.findItemStack(HC, grainName + "Item", 1);
ItemStack grainSeed = GameRegistry.findItemStack(HC, grainName + "seedItem", 1);
Block grainBlock = GameRegistry.findBlock(HC, "pam" + grainName + "Crop");
if (grain != null && wheatamount.stackSize > 0) {
Proxies.common.addRecipe(wheatamount, " X ", "X#X", " X ", '#', Blocks.dirt, 'X', grain);
}
if (grainSeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{grainSeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (grainSeed != null && grainBlock != null) {
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(grainSeed, grainBlock, 7));
}
plants.add(grainName);
}
for (String treeFruitName : treeFruits) {
ItemStack treeFruit = GameRegistry.findItemStack(HC, treeFruitName + "Item", 1);
Block treeFruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeFruitName.charAt(0)) + treeFruitName.substring(1)));
if (treeFruitBlock != null) {
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(treeFruitBlock, 2));
}
if (treeFruit != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{treeFruit}, Fluids.JUICE.getFluid(juiceAmount));
}
plants.add(treeFruitName);
}
for (String treeName : trees) {
Block fruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1)));
if (fruitBlock != null) {
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(fruitBlock, 2));
}
plants.add(treeName);
}
for (String treeName : treesSpecial) {
Block fruitBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(treeName.charAt(0)) + treeName.substring(1)));
if (fruitBlock != null) {
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(fruitBlock, 2));
}
}
for (String cropName : genericCrops) {
ItemStack genericCropSeed = GameRegistry.findItemStack(HC, cropName + "seedItem", 1);
Block genericCropBlock = GameRegistry.findBlock(HC, "pam" + cropName + "Crop");
if (genericCropSeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{genericCropSeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (genericCropSeed != null && genericCropBlock != null) {
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(genericCropSeed, genericCropBlock, 7));
}
plants.add(cropName);
}
for (String plantName : plants.build()) {
ItemStack plant = GameRegistry.findItemStack(HC, plantName + "Item", 1);
if (plant != null) {
RecipeUtil.injectLeveledRecipe(plant, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
}
}
for (String cropnutName : cropNuts) {
ItemStack cropnut = GameRegistry.findItemStack(HC, cropnutName + "Item", 1);
ItemStack cropnutSeed = GameRegistry.findItemStack(HC, cropnutName + "seedItem", 1);
Block cropnutBlock = GameRegistry.findBlock(HC, "pam" + cropnutName + "Crop");
if (cropnutSeed != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{cropnutSeed}, Fluids.SEEDOIL.getFluid(seedamount));
}
if (cropnutSeed != null && cropnutBlock != null) {
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(cropnutSeed, cropnutBlock, 7));
}
if (cropnut != null) {
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{cropnut}, Fluids.SEEDOIL.getFluid(3 * seedamount));
}
}
for (String nutName : nuts) {
ItemStack nut = GameRegistry.findItemStack(HC, nutName + "Item", 1);
Block nutBlock = GameRegistry.findBlock(HC, "pam" + (Character.toUpperCase(nutName.charAt(0)) + nutName.substring(1)));
if (nutBlock != null) {
Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(nutBlock, 2));
}
if (nut != null) {
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{nut}, Fluids.SEEDOIL.getFluid(3 * seedamount));
}
}
ItemStack hcHoneyItem = GameRegistry.findItemStack(HC, "honeyItem", 1);
if (hcHoneyItem != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{hcHoneyItem}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP));
}
ItemStack hcBeeswaxItem = GameRegistry.findItemStack(HC, "beeswaxItem", 1);
if (hcBeeswaxItem != null) {
Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.capsule"), "XXX ", 'X', hcBeeswaxItem);
}
}
}
@@ -88,6 +88,7 @@ public class PluginManager {
EQUIVELENT_EXCHANGE(new PluginEE()),
FARM_CRAFTORY(new PluginFarmCraftory()),
INDUSTRIALCRAFT(new PluginIC2()),
HARVESTCRAFT(new PluginHarvestCraft()),
NATURA(new PluginNatura()),
UNDERGROUND_BIOMES(new PluginUndergroundBiomes());