Package forestry.api.farming
Interface IFarmHousing
- All Superinterfaces:
IErrorLogicSource,IExtentCache
- All Known Subinterfaces:
IFarmController
The IFarmHousing describes a forestry farm handler.
It contains methods to interact with the farm itself.
Can be used in IFarmLogic's to remove fluid or add products.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPendingProduct(net.minecraft.world.item.ItemStack stack) Adds a product to an internal buffer of items, which will later be added to the inventory.default booleancanPlantSoil(boolean manual) Checks if the farm can plant soil.booleandoWork()net.minecraft.core.Vec3igetArea()net.minecraft.core.BlockPosPosition of the farm.net.minecraft.core.BlockPosgetFarmCorner(net.minecraft.core.Direction direction) Receives the corner position of the given direction.getFarmLogic(net.minecraft.core.Direction direction) Receives the logic of the given direction.Receives a collection with all logics of this farm.net.minecraft.core.Vec3iintgetStoredFertilizerScaled(int scale) The percentage of fertilizer stored my the farm multiplied by the given scale.booleanhasLiquid(net.minecraftforge.fluids.FluidStack liquid) Checks if the given liquid and amount is contained in the internal tank.default booleanisSquare()If the farmland area is square.default booleanisValidPlatform(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) booleanplantGermling(IFarmable farmable, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction) Callback forIFarmLogics to plant a sapling, seed, germling, stem.voidremoveLiquid(net.minecraftforge.fluids.FluidStack liquid) Removes the given liquid from the internal tank if possible.voidresetFarmLogic(net.minecraft.core.Direction direction) Resets the farm logic off the given direction to the default logic (ARBOREAL).voidsetFarmLogic(net.minecraft.core.Direction direction, IFarmLogic logic) Sets the farm logic of one direction of the farm.Methods inherited from interface forestry.api.core.IErrorLogicSource
getErrorLogicMethods inherited from interface forestry.api.farming.IExtentCache
cleanExtents, getExtents, getValidExtent, getValidPosition, increaseExtent, setExtents
-
Method Details
-
getCoords
net.minecraft.core.BlockPos getCoords()Position of the farm. Mostly used by internal logic.If the farm is a multiblock, the position is based in the center.
- Returns:
- Position of the farm.
-
getArea
net.minecraft.core.Vec3i getArea()- Returns:
- The area of the farmland of the farm.
-
getOffset
net.minecraft.core.Vec3i getOffset()- Returns:
- The offset used by the farm to create a bounding box for the harvest logic.
-
doWork
boolean doWork()- Returns:
- true if any work was done, false otherwise.
-
hasLiquid
boolean hasLiquid(net.minecraftforge.fluids.FluidStack liquid) Checks if the given liquid and amount is contained in the internal tank.- Parameters:
liquid- The liquid to be checked- Returns:
- True if the tank contains the liquid, false otherwise
-
removeLiquid
void removeLiquid(net.minecraftforge.fluids.FluidStack liquid) Removes the given liquid from the internal tank if possible.- Parameters:
liquid- The liquid to be removed
-
plantGermling
boolean plantGermling(IFarmable farmable, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction) Callback forIFarmLogics 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.- Returns:
- true if planting was successful, false otherwise.
-
isValidPlatform
default boolean isValidPlatform(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) -
isSquare
default boolean isSquare()If the farmland area is square.- Returns:
- True if the farmland area is a square, false otherwise
-
canPlantSoil
default boolean canPlantSoil(boolean manual) Checks if the farm can plant soil.- Parameters:
manual- If true the manual mode of the farm is enabled- Returns:
- True if the farm is able to place soil, false otherwise
-
getFarmInventory
IFarmInventory getFarmInventory()- Returns:
- The inventory instance of this farm.
-
addPendingProduct
void addPendingProduct(net.minecraft.world.item.ItemStack stack) Adds a product to an internal buffer of items, which will later be added to the inventory.- Parameters:
stack- The stack to be added to the inventory.
-
setFarmLogic
Sets the farm logic of one direction of the farm.- Parameters:
direction- The direction of the farm to be setlogic- The farm logic that direction should be set to
-
resetFarmLogic
void resetFarmLogic(net.minecraft.core.Direction direction) Resets the farm logic off the given direction to the default logic (ARBOREAL).- Parameters:
direction- The direction to reset
-
getFarmLogic
Receives the logic of the given direction.- Parameters:
direction- The direction of the logic to get.- Returns:
- The logic that is located on this side of the farm.
-
getFarmLogics
Collection<IFarmLogic> getFarmLogics()Receives a collection with all logics of this farm. By default this ether contains 1 or 4 logics.- Returns:
- A collection which contains all logics of this farm.
-
getStoredFertilizerScaled
int getStoredFertilizerScaled(int scale) The percentage of fertilizer stored my the farm multiplied by the given scale.- Parameters:
scale- Value used to scale the fertilizer percentage- Returns:
- The percentage of fertilizer stored my the farm multiplied by the given scale.
-
getFarmCorner
net.minecraft.core.BlockPos getFarmCorner(net.minecraft.core.Direction direction) Receives the corner position of the given direction. Mainly used for internal logic to position the crops and germlings.- Parameters:
direction- The direction to receive- Returns:
- The position of the direction corner.
-