mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Merge pull request #1948 from ForestryMC/farm
Reintroduce the old-style farm and Rebalance electron tubes
This commit is contained in:
172 files changed
+4237
-1202
No files matched your search
@@ -7,11 +7,17 @@ package forestry.api.circuits;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public interface ICircuit {
|
||||
String getUID();
|
||||
|
||||
String getUnlocalizedName();
|
||||
|
||||
default String getLocalizedName(){
|
||||
return I18n.translateToLocal(getUnlocalizedName());
|
||||
}
|
||||
|
||||
boolean isCircuitable(Object tile);
|
||||
|
||||
void onInsertion(int slot, Object tile);
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.farming;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
//TODO: Remove this class in 1.13
|
||||
@Deprecated
|
||||
public class Farmables {
|
||||
/**
|
||||
* Can be used to add IFarmables to some of the vanilla farm logics.
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.farming;
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
|
||||
public interface IFarmHousing extends IErrorLogicSource {
|
||||
|
||||
BlockPos getCoords();
|
||||
@@ -33,10 +35,36 @@ public interface IFarmHousing extends IErrorLogicSource {
|
||||
* Will remove the appropriate germling from the farm's inventory.
|
||||
* It's up to the logic to only call this on a valid location.
|
||||
*
|
||||
* @deprecated TODO remove this method in 1.13
|
||||
*
|
||||
* @return true if planting was successful, false otherwise.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean plantGermling(IFarmable farmable, World world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
default boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction){
|
||||
return plantGermling(farmable, world, pos);
|
||||
}
|
||||
|
||||
default boolean isValidPlatform(World world, BlockPos pos){
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isSquare(){
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean canPlantSoil(boolean manual){
|
||||
return true;
|
||||
}
|
||||
|
||||
/* INTERACTION WITH HATCHES */
|
||||
IFarmInventory getFarmInventory();
|
||||
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface IFarmInventory {
|
||||
IInventory getResourcesInventory();
|
||||
|
||||
IInventory getFertilizerInventory();
|
||||
|
||||
|
||||
}
|
||||
@@ -8,39 +8,136 @@ package forestry.api.farming;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
/**
|
||||
* The IFarmLogic is used by farm blocks and multi-blocks to cultivate and harvest crops and plants.
|
||||
*
|
||||
* Every farm block has only ony one logic a multi-block farm has four, one for every direction.
|
||||
*/
|
||||
public interface IFarmLogic {
|
||||
|
||||
/**
|
||||
* @return The amount of fertilizer that the {@link IFarmHousing} automatically removes after this logic cultivated
|
||||
* a block or harvested a crop.
|
||||
*/
|
||||
int getFertilizerConsumption();
|
||||
|
||||
/**
|
||||
* @param hydrationModifier A modifier that depends on the weather and the biome of the farm.
|
||||
*
|
||||
* @return The amount of water that the {@link IFarmHousing} automatically removes after this logic cultivated
|
||||
* a block or harvested a crop.
|
||||
*/
|
||||
int getWaterConsumption(float hydrationModifier);
|
||||
|
||||
/**
|
||||
* Checks if the given stack is a resource or a soil that this logic uses to grow plants on or to create other
|
||||
* products like peat.
|
||||
*/
|
||||
boolean isAcceptedResource(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* Checks if the given stack is a germling (plantable sapling, seed, etc.) for any {@link IFarmable} of this farm.
|
||||
*/
|
||||
boolean isAcceptedGermling(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* Collects all items that are laying on the ground and are in the {@link IFarmHousing#getArea()} of the farm.
|
||||
*
|
||||
* @param world The world of the farm.
|
||||
* @param farmHousing The farm that uses this logic.
|
||||
*
|
||||
* @return A collection that contains all items that were collected.
|
||||
*/
|
||||
NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing);
|
||||
|
||||
/**
|
||||
* Tries to cultivate one or more blocks at the given position and with the given extent.
|
||||
*
|
||||
* @param world The world of the farm.
|
||||
* @param farmHousing The farm that uses this logic.
|
||||
* @param pos The position at that the logic should start to cultivate.
|
||||
* @param direction The direction of the extension.
|
||||
* @param extent How many blocks this logic has to cultivate after it cultivated the block at the given position.
|
||||
* The positions of the next blocks are having a offset in the given direction.
|
||||
* @return True if the logic has cultivated any block.
|
||||
*/
|
||||
boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent);
|
||||
|
||||
/**
|
||||
* Tries to harvest one or more blocks at the given position and with the given extent.
|
||||
*
|
||||
* @param world The world of the farm.
|
||||
* @param pos The position at that the logic should start to harvest.
|
||||
* @param direction The direction of the extension.
|
||||
* @param extent How many blocks this logic tries to harvest after it has tried to harvested the block at the given position.
|
||||
* The positions of the next blocks are having a offset in the given direction.
|
||||
* @return True if the logic has cultivated any block.
|
||||
*/
|
||||
Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent);
|
||||
|
||||
IFarmLogic setManual(boolean manual);
|
||||
/**
|
||||
* Returns the {@link IFarmProperties} that created this logic.
|
||||
*
|
||||
* @since Forestry 5.8
|
||||
*
|
||||
* @return Returns the {@link IFarmProperties} that created this logic. Returns a fake instance from
|
||||
* {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8.
|
||||
* TODO: Remove "default" from this method in 1.13
|
||||
*/
|
||||
default IFarmProperties getProperties(){
|
||||
return ForestryAPI.farmRegistry.createFakeInstance(this);
|
||||
}
|
||||
|
||||
void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ResourceLocation getTextureMap();
|
||||
/**
|
||||
* @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmProperties} and
|
||||
* have a immutable manual state. TODO Remove this method in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
default IFarmLogic setManual(boolean manual){
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link IFarmRegistry#getProperties(String)} to get the {@link IFarmProperties} for the farm logic and register the soil
|
||||
* with {@link IFarmProperties#registerSoil(ItemStack, IBlockState, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
default void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){
|
||||
//
|
||||
}
|
||||
|
||||
default String getUnlocalizedName(){
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Localized short, human-readable identifier used in the farm gui and in tooltips.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/* GUI ONLY */
|
||||
/**
|
||||
* @deprecated No longer needed because mc always uses the same map for blocks and items.
|
||||
* TODO remove this method in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
default ResourceLocation getTextureMap(){
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemStack that represents this farm logic. Used as an icon for the farm logic.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package forestry.api.farming;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
public interface IFarmProperties {
|
||||
|
||||
/**
|
||||
* Can be used to register a {@link IBlockState} as a valid soil.
|
||||
*/
|
||||
default void registerSoil(ItemStack resource, IBlockState soilState){
|
||||
registerSoil(resource, soilState, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to register a {@link IBlockState} as a valid soil.
|
||||
*/
|
||||
void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
|
||||
|
||||
/**
|
||||
* Adds the {@link IFarmable}s that where registered with the given identifier.
|
||||
*/
|
||||
void registerFarmables(String identifier);
|
||||
|
||||
/**
|
||||
* @return true if the given block state is a valid soil state.
|
||||
*/
|
||||
boolean isAcceptedSoil(IBlockState blockState);
|
||||
|
||||
/**
|
||||
* @return true if the given stack is the {@link ItemStack} of a soil.
|
||||
*/
|
||||
boolean isAcceptedResource(ItemStack itemStack);
|
||||
|
||||
Collection<ISoil> getSoils();
|
||||
|
||||
Collection<IFarmable> getFarmables();
|
||||
|
||||
/**
|
||||
* Returns the instance of the manual or managed {@link IFarmLogic}.
|
||||
*/
|
||||
IFarmLogic getLogic(boolean manuel);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package forestry.api.farming;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -14,15 +15,35 @@ public interface IFarmRegistry {
|
||||
|
||||
/**
|
||||
* Registers farming logic in registry under given identifier
|
||||
* @param identifier Valid identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom
|
||||
* @param identifier Valid identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom
|
||||
* @param logic corresponding instance of logic
|
||||
*
|
||||
* @deprecated Since Forestry 5.8. Use {@link #registerLogic(String, BiFunction, String...)} or
|
||||
* {@link #registerLogic(String, IFarmProperties)}.
|
||||
*/
|
||||
void registerFarmLogic(String identifier, IFarmLogic logic);
|
||||
|
||||
@Deprecated
|
||||
void registerLogic(String identifier, IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Registers farming logic in registry
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance);
|
||||
|
||||
/**
|
||||
* Registers farming logic in registry under given identifier
|
||||
*
|
||||
* @param identifier Valid identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom
|
||||
* @param logicFactory factory that creates the corresponding instance of logic
|
||||
* @param farmablesIdentifiers Identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
IFarmProperties registerLogic(String identifier, BiFunction<IFarmProperties, Boolean, IFarmLogic> logicFactory, String... farmablesIdentifiers);
|
||||
|
||||
/**
|
||||
* Can be used to add IFarmables to some of the vanilla farm logics.
|
||||
* <p>
|
||||
* Identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom
|
||||
* Identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom
|
||||
*/
|
||||
void registerFarmables(String identifier, IFarmable... farmable);
|
||||
|
||||
@@ -32,14 +53,18 @@ public interface IFarmRegistry {
|
||||
* Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic.
|
||||
*
|
||||
* @return Null if the farming plugin is not active.
|
||||
*
|
||||
* @deprecated Since Forestry 5.8. Use {@link #createCropLogic(IFarmProperties, boolean, ISimpleFarmLogic)} instead.
|
||||
*/
|
||||
@Nullable
|
||||
IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic);
|
||||
@Deprecated
|
||||
default IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemStack
|
||||
* @param value The value of the fertitlizer.The value of the forestry fertelizer is 500.
|
||||
* @param value The value of the fertitlizer. The value of the forestry fertelizer is 500.
|
||||
*/
|
||||
void registerFertilizer(ItemStack itemStack, int value);
|
||||
|
||||
@@ -47,5 +72,28 @@ public interface IFarmRegistry {
|
||||
* @return The value of the fertitlizer
|
||||
*/
|
||||
int getFertilizeValue(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Returns a fake {@link IFarmProperties} that returns the given logic at {@link IFarmProperties#getLogic(boolean)}.
|
||||
*
|
||||
* @since Forestry 5.8
|
||||
* @deprecated Only for backwards comparability.
|
||||
*/
|
||||
@Deprecated
|
||||
IFarmProperties createFakeInstance(IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic.
|
||||
*
|
||||
* @return Null if the farming plugin is not active.
|
||||
*/
|
||||
@Nullable
|
||||
IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic);
|
||||
|
||||
/**
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
@Nullable
|
||||
IFarmProperties getProperties(String identifier);
|
||||
|
||||
}
|
||||
@@ -20,8 +20,19 @@ 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.
|
||||
* @deprecated Since Forestry 5.8. Use the version below. TODO Remove this method in 1.13
|
||||
*/
|
||||
boolean isSaplingAt(World world, BlockPos pos);
|
||||
@Deprecated
|
||||
default boolean isSaplingAt(World world, BlockPos pos){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
default boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState){
|
||||
return isSaplingAt(world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise.
|
||||
|
||||
@@ -8,7 +8,9 @@ package forestry.api.farming;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* A simple version of the IFarmLogic.
|
||||
* A simple version of the IFarmLogic.
|
||||
*
|
||||
* @apiNote TODO Remove this in 1.13
|
||||
*/
|
||||
public interface ISimpleFarmLogic {
|
||||
|
||||
@@ -16,7 +18,11 @@ public interface ISimpleFarmLogic {
|
||||
* @return the itemStack that represents this farm logic. Used as an icon for the farm logic.
|
||||
*/
|
||||
ItemStack getIconItemStack();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Since 5.8
|
||||
*/
|
||||
@Deprecated
|
||||
Iterable<IFarmable> getSeeds();
|
||||
|
||||
String getName();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package forestry.api.farming;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
public interface ISoil {
|
||||
|
||||
ItemStack getResource();
|
||||
|
||||
IBlockState getSoilState();
|
||||
|
||||
boolean hasMetaData();
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "2.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|farming")
|
||||
@API(apiVersion = "5.8.0", owner = "ForestryAPI|core", provides = "ForestryAPI|farming")
|
||||
package forestry.api.farming;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
Reference in new issue
Block a user