mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Improve Farm Logic System and add ring farm layout
This commit is contained in:
1 parent
521514f3d2
commit
10fec50457
53 files changed
+1019
-534
No files matched your search
@@ -61,6 +61,10 @@ public interface IFarmHousing extends IErrorLogicSource {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean canPlantSoil(boolean manual){
|
||||
return true;
|
||||
}
|
||||
|
||||
/* INTERACTION WITH HATCHES */
|
||||
IFarmInventory getFarmInventory();
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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 IFarmInstance {
|
||||
|
||||
default void registerSoil(ItemStack resource, IBlockState soilState){
|
||||
registerSoil(resource, soilState, false);
|
||||
}
|
||||
|
||||
void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
|
||||
|
||||
boolean isAcceptedSoil(IBlockState blockState);
|
||||
|
||||
boolean isAcceptedResource(ItemStack itemStack);
|
||||
|
||||
String getIdentifier();
|
||||
|
||||
Collection<ISoil> getSoils();
|
||||
|
||||
Collection<IFarmable> getFarmables();
|
||||
|
||||
IFarmLogic getLogic(boolean manuel);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -17,10 +18,20 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
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();
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
boolean isAcceptedResource(ItemStack itemstack);
|
||||
@@ -33,20 +44,50 @@ public interface IFarmLogic {
|
||||
|
||||
Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent);
|
||||
|
||||
IFarmLogic setManual(boolean manual);
|
||||
/**
|
||||
* @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmInstance} and
|
||||
* have a immutable manual state. TODO Remove this method in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
default IFarmLogic setManual(boolean manual){
|
||||
return this;
|
||||
}
|
||||
|
||||
void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
|
||||
/**
|
||||
* @since Forestry 5.8
|
||||
*
|
||||
* @return Returns the {@link IFarmInstance} that created this logic. Returns a fake instance from
|
||||
* {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8.
|
||||
*/
|
||||
default IFarmInstance getInstance(){
|
||||
return ForestryAPI.farmRegistry.createFakeInstance(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link IFarmRegistry#getFarm(String)} to get the soil container for the farm logic and register the soil
|
||||
* with {@link IFarmInstance#registerSoil(ItemStack, IBlockState, boolean)}.
|
||||
*/
|
||||
@Deprecated
|
||||
default void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A short localized name for this logic.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/* GUI ONLY */
|
||||
|
||||
/**
|
||||
* @deprecated TODO remove this method in 1.13
|
||||
* @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)
|
||||
ResourceLocation getTextureMap();
|
||||
default ResourceLocation getTextureMap(){
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the itemStack that represents this farm logic. Used as an icon for the farm logic.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -16,9 +17,29 @@ public interface IFarmRegistry {
|
||||
* Registers farming logic in registry under given identifier
|
||||
* @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(IFarmInstance)}.
|
||||
*/
|
||||
void registerFarmLogic(String identifier, IFarmLogic logic);
|
||||
|
||||
@Deprecated
|
||||
void registerLogic(String identifier, IFarmLogic logic);
|
||||
|
||||
/**
|
||||
* Registers farming logic in registry
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
IFarmInstance registerLogic(IFarmInstance 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
|
||||
*/
|
||||
IFarmInstance registerLogic(String identifier, BiFunction<IFarmInstance, Boolean, IFarmLogic> logicFactory, String... farmablesIdentifiers);
|
||||
|
||||
/**
|
||||
* Can be used to add IFarmables to some of the vanilla farm logics.
|
||||
* <p>
|
||||
@@ -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(IFarmInstance, 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,32 @@ public interface IFarmRegistry {
|
||||
* @return The value of the fertitlizer
|
||||
*/
|
||||
int getFertilizeValue(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Returns a fake {@link IFarmInstance} that returns the given logic at {@link IFarmInstance#getLogic(boolean)}.
|
||||
*
|
||||
* @since Forestry 5.8
|
||||
* @deprecated Only for backwards comparability.
|
||||
*/
|
||||
@Deprecated
|
||||
IFarmInstance 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(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param identifier
|
||||
* @return
|
||||
*
|
||||
* @since Forestry 5.8
|
||||
*/
|
||||
@Nullable
|
||||
IFarmInstance getFarm(String identifier);
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user