Move files

This commit is contained in:
Johann Bernhardt committed 2021-11-22 12:37:53 +01:00
1 parent a958073079
commit 3429114d2a
274 files changed
+37547 -11

No files matched your search

@@ -0,0 +1,50 @@
/*******************************************************************************
* 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.minecraftforge.common.util.ForgeDirection;
/**
* 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, int x, int y, int z, FarmDirection direction, int extent) {
}
@Override
public void hasScheduledHarvest(Collection<ICrop> harvested, IFarmLogic logic, int x, int y, int z, 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.minecraftforge.common.util.ForgeDirection;
public enum FarmDirection {
NORTH(ForgeDirection.NORTH),
EAST(ForgeDirection.EAST),
SOUTH(ForgeDirection.SOUTH),
WEST(ForgeDirection.WEST);
private final ForgeDirection forgeDirection;
FarmDirection(ForgeDirection forgeDirection) {
this.forgeDirection = forgeDirection;
}
public ForgeDirection getForgeDirection() {
return forgeDirection;
}
public static FarmDirection getFarmDirection(ForgeDirection 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,48 @@
/*******************************************************************************
* 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.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, int x, int y, int z);
/* 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,55 @@
/*******************************************************************************
* 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.minecraftforge.common.util.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!
*/
void hasCollected(Collection<ItemStack> collected, IFarmLogic logic);
/**
* Called after farmland has successfully been cultivated by a farm logic.
*/
void hasCultivated(IFarmLogic logic, int x, int y, int z, 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, int x, int y, int z, 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,41 @@
/*******************************************************************************
* 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.IIcon;
import net.minecraft.util.ResourceLocation;
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, FarmDirection direction, int extent);
Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent);
IFarmLogic setManual(boolean manual);
@SideOnly(Side.CLIENT)
IIcon getIcon();
ResourceLocation getSpriteSheet();
String getName();
}
@@ -0,0 +1,45 @@
/*******************************************************************************
* 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.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, int x, int y, int 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);
/**
* @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, int x, int y, int z);
}
@@ -0,0 +1,8 @@
/*******************************************************************************
* 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 cpw.mods.fml.common.API;