Get things compiling.

Move ForestryAPI into the Forestry project instead of as a submodule
Include the new RF API
Remove code for mods that have not yet ported to 1.8.9 (add it back later)
Bump version to 5.0.0
This commit is contained in:
mezz committed 2016-02-20 19:51:49 -08:00
1 parent 73812d8765
commit 8da0c0dc95
325 files changed
+9600 -4026

No files matched your search

@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
/**
* Easily extendable default farmListener.
* By itself, this farmListener does nothing.
* FarmListeners should inherit from this class unless they need to listen for everything.
*/
public class DefaultFarmListener implements IFarmListener {
@Override
public boolean beforeCropHarvest(ICrop crop) {
return false;
}
@Override
public void afterCropHarvest(Collection<ItemStack> harvested, ICrop crop) {
}
@Override
public void hasCollected(Collection<ItemStack> collected, IFarmLogic logic) {
}
@Override
public void hasCultivated(IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent) {
}
@Override
public void hasScheduledHarvest(Collection<ICrop> harvested, IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent) {
}
@Override
public boolean cancelTask(IFarmLogic logic, FarmDirection direction) {
return false;
}
}
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import net.minecraft.util.EnumFacing;
public enum FarmDirection {
NORTH(EnumFacing.NORTH),
EAST(EnumFacing.EAST),
SOUTH(EnumFacing.SOUTH),
WEST(EnumFacing.WEST);
private final EnumFacing forgeDirection;
FarmDirection(EnumFacing forgeDirection) {
this.forgeDirection = forgeDirection;
}
public EnumFacing getForgeDirection() {
return forgeDirection;
}
public static FarmDirection getFarmDirection(EnumFacing forgeDirection) {
switch (forgeDirection) {
case NORTH: return NORTH;
case EAST: return EAST;
case SOUTH: return SOUTH;
case WEST: return WEST;
}
return null;
}
}
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import java.util.Collection;
import java.util.HashMap;
public class Farmables {
/**
* Can be used to add IFarmables to some of the vanilla farm logics.
*
* Identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom
*/
public static HashMap<String, Collection<IFarmable>> farmables = new HashMap<String, Collection<IFarmable>>();
}
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import java.util.Collection;
import net.minecraft.item.ItemStack;
public interface ICrop {
/**
* Harvests this crop. Performs the necessary manipulations to set the crop into a "harvested" state.
*
* @return Products harvested.
*/
Collection<ItemStack> harvest();
}
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.core.IErrorLogicSource;
public interface IFarmHousing extends IErrorLogicSource {
int[] getCoords();
int[] getArea();
int[] getOffset();
World getWorld();
/**
* @return true if any work was done, false otherwise.
*/
boolean doWork();
boolean hasLiquid(FluidStack liquid);
void removeLiquid(FluidStack liquid);
/**
* Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem.
* Will remove the appropriate germling from the farm's inventory.
* It's up to the logic to only call this on a valid location.
*
* @return true if planting was successful, false otherwise.
*/
boolean plantGermling(IFarmable farmable, World world, BlockPos pos);
/* INTERACTION WITH HATCHES */
IFarmInventory getFarmInventory();
/* LOGIC */
void setFarmLogic(FarmDirection direction, IFarmLogic logic);
void resetFarmLogic(FarmDirection direction);
IFarmLogic getFarmLogic(FarmDirection direction);
/* GUI */
int getStoredFertilizerScaled(int scale);
}
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public interface IFarmInventory {
boolean hasResources(ItemStack[] resources);
void removeResources(ItemStack[] resources);
boolean acceptsAsGermling(ItemStack itemstack);
boolean acceptsAsResource(ItemStack itemstack);
boolean acceptsAsFertilizer(ItemStack itemstack);
IInventory getProductInventory();
IInventory getGermlingsInventory();
IInventory getResourcesInventory();
IInventory getFertilizerInventory();
}
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
public interface IFarmListener {
/**
* Called before a crop is harvested.
*
* @param crop ICrop about to be harvested.
* @return true to cancel further processing of this crop.
*/
boolean beforeCropHarvest(ICrop crop);
/**
* Called after a crop has been harvested, but before harvested items are stowed in the farms inventory.
*
* @param harvested Collection of harvested stacks. May be manipulated. Ensure removal of stacks with 0 or less items!
* @param crop Harvested {@link ICrop}
*/
void afterCropHarvest(Collection<ItemStack> harvested, ICrop crop);
/**
* Called after the stack of collected items has been returned by the farm logic, but before it is added to the farm's pending queue.
*
* @param collected Collection of collected stacks. May be manipulated. Ensure removal of stacks with 0 or less items!
*/
void hasCollected(Collection<ItemStack> collected, IFarmLogic logic);
/**
* Called after farmland has successfully been cultivated by a farm logic.
*/
void hasCultivated(IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent);
/**
* Called after the stack of harvested crops has been returned by the farm logic, but before it is added to the farm's pending queue.
*/
void hasScheduledHarvest(Collection<ICrop> harvested, IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent);
/**
* Can be used to cancel farm task on a per side/{@link IFarmLogic} basis.
*
* @return true to skip any work action on the given logic and direction for this work cycle.
*/
boolean cancelTask(IFarmLogic logic, FarmDirection direction);
}
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import java.util.Collection;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IFarmLogic {
int getFertilizerConsumption();
int getWaterConsumption(float hydrationModifier);
boolean isAcceptedResource(ItemStack itemstack);
boolean isAcceptedGermling(ItemStack itemstack);
Collection<ItemStack> collect();
boolean cultivate(BlockPos pos, FarmDirection direction, int extent);
Collection<ICrop> harvest(BlockPos pos, FarmDirection direction, int extent);
IFarmLogic setManual(boolean manual);
@SideOnly(Side.CLIENT)
ResourceLocation getTextureMap();
String getName();
@SideOnly(Side.CLIENT)
ItemStack getStack();
}
@@ -0,0 +1,46 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
* IFarmable describes a crop or other harvestable object and can be used to inspect item stacks and blocks for matches.
*/
public interface IFarmable {
/**
* @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
*/
boolean isSaplingAt(World world, BlockPos pos);
/**
* @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise.
*/
ICrop getCropAt(World world, BlockPos pos);
/**
* @return true if the item is a valid germling (plantable sapling, seed, etc.) for this type.
*/
boolean isGermling(ItemStack itemstack);
/**
* @return true if the item is something that can drop from this type without actually being harvested as a crop. (Apples or sapling from decaying leaves.)
*/
boolean isWindfall(ItemStack itemstack);
/**
* Plants a sapling by manipulating the world. The {@link IFarmLogic} should have verified the given location as valid. Called by the {@link IFarmHousing}
* which handles resources.
*
* @return true on success, false otherwise.
*/
boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos);
}
@@ -0,0 +1,9 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion="2.1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming")
package forestry.api.farming;
import net.minecraftforge.fml.common.API;