Test with stuff + Forestry potential support
This commit is contained in:
parent
5b05cf651b
commit
bd26e441cb
174 changed files with 5602 additions and 0 deletions
15
BM_src/forestry/api/farming/Farmables.java
Normal file
15
BM_src/forestry/api/farming/Farmables.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
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>>();
|
||||
|
||||
public static IFarmInterface farmInterface;
|
||||
}
|
16
BM_src/forestry/api/farming/ICrop.java
Normal file
16
BM_src/forestry/api/farming/ICrop.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
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();
|
||||
|
||||
}
|
12
BM_src/forestry/api/farming/IFarmComponent.java
Normal file
12
BM_src/forestry/api/farming/IFarmComponent.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import forestry.api.core.ITileStructure;
|
||||
|
||||
public interface IFarmComponent extends ITileStructure {
|
||||
|
||||
boolean hasFunction();
|
||||
|
||||
void registerListener(IFarmListener listener);
|
||||
|
||||
void removeListener(IFarmListener listener);
|
||||
}
|
68
BM_src/forestry/api/farming/IFarmHousing.java
Normal file
68
BM_src/forestry/api/farming/IFarmHousing.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFarmHousing {
|
||||
|
||||
int[] getCoords();
|
||||
|
||||
int[] getArea();
|
||||
|
||||
int[] getOffset();
|
||||
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Will run the work cycle on a master TE. Will do nothing on any other farm component.
|
||||
*
|
||||
* @return true if any work was done, false otherwise.
|
||||
*/
|
||||
boolean doWork();
|
||||
|
||||
boolean hasLiquid(FluidStack liquid);
|
||||
|
||||
void removeLiquid(FluidStack liquid);
|
||||
|
||||
boolean hasResources(ItemStack[] resources);
|
||||
|
||||
void removeResources(ItemStack[] resources);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param farmable
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return true if planting was successful, false otherwise.
|
||||
*/
|
||||
boolean plantGermling(IFarmable farmable, World world, int x, int y, int z);
|
||||
|
||||
/* INTERACTION WITH HATCHES */
|
||||
boolean acceptsAsGermling(ItemStack itemstack);
|
||||
|
||||
boolean acceptsAsResource(ItemStack itemstack);
|
||||
|
||||
boolean acceptsAsFertilizer(ItemStack itemstack);
|
||||
|
||||
/* LOGIC */
|
||||
/**
|
||||
* Set a farm logic for the given direction. UP/DOWN/UNKNOWN are invalid!
|
||||
*
|
||||
* @param direction
|
||||
* @param logic
|
||||
*/
|
||||
void setFarmLogic(ForgeDirection direction, IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Reset the farm logic for the given direction to default. UP/DOWN/UNKNOWN are invalid!
|
||||
*
|
||||
* @param direction
|
||||
*/
|
||||
void resetFarmLogic(ForgeDirection direction);
|
||||
}
|
15
BM_src/forestry/api/farming/IFarmInterface.java
Normal file
15
BM_src/forestry/api/farming/IFarmInterface.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import forestry.api.core.IStructureLogic;
|
||||
|
||||
public interface IFarmInterface {
|
||||
|
||||
/**
|
||||
* Creates {@link IStructureLogic} for use in farm components.
|
||||
*
|
||||
* @param structure
|
||||
* {@link IFarmComponent} to create the logic for.
|
||||
* @return {@link IStructureLogic} for use in farm components
|
||||
*/
|
||||
IStructureLogic createFarmStructureLogic(IFarmComponent structure);
|
||||
}
|
71
BM_src/forestry/api/farming/IFarmListener.java
Normal file
71
BM_src/forestry/api/farming/IFarmListener.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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!
|
||||
* @param logic
|
||||
*/
|
||||
void hasCollected(Collection<ItemStack> collected, IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Called after farmland has successfully been cultivated by a farm logic.
|
||||
*
|
||||
* @param logic
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param direction
|
||||
* @param extent
|
||||
*/
|
||||
void hasCultivated(IFarmLogic logic, int x, int y, int z, ForgeDirection 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.
|
||||
*
|
||||
* @param harvested
|
||||
* @param logic
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param direction
|
||||
* @param extent
|
||||
*/
|
||||
void hasScheduledHarvest(Collection<ICrop> harvested, IFarmLogic logic, int x, int y, int z, ForgeDirection direction, int extent);
|
||||
|
||||
/**
|
||||
* Can be used to cancel farm task on a per side/{@link IFarmLogic} basis.
|
||||
*
|
||||
* @param logic
|
||||
* @param direction
|
||||
* @return true to skip any work action on the given logic and direction for this work cycle.
|
||||
*/
|
||||
boolean cancelTask(IFarmLogic logic, ForgeDirection direction);
|
||||
}
|
34
BM_src/forestry/api/farming/IFarmLogic.java
Normal file
34
BM_src/forestry/api/farming/IFarmLogic.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.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(int x, int y, int z, ForgeDirection direction, int extent);
|
||||
|
||||
Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
Icon getIcon();
|
||||
|
||||
ResourceLocation getSpriteSheet();
|
||||
|
||||
String getName();
|
||||
}
|
54
BM_src/forestry/api/farming/IFarmable.java
Normal file
54
BM_src/forestry/api/farming/IFarmable.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package forestry.api.farming;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* IGermling describes a crop or other harvestable object and can be used to inspect item stacks and blocks for matches.
|
||||
*/
|
||||
public interface IFarmable {
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @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, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise.
|
||||
*/
|
||||
ICrop getCropAt(World world, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @param itemstack
|
||||
* @return true if the item is a valid germling (plantable sapling, seed, etc.) for this type.
|
||||
*/
|
||||
boolean isGermling(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* @param 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.
|
||||
*
|
||||
* @param germling
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z);
|
||||
|
||||
}
|
3
BM_src/forestry/api/farming/package-info.java
Normal file
3
BM_src/forestry/api/farming/package-info.java
Normal file
|
@ -0,0 +1,3 @@
|
|||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming")
|
||||
package forestry.api.farming;
|
||||
import cpw.mods.fml.common.API;
|
Loading…
Add table
Add a link
Reference in a new issue