Class Crop
java.lang.Object
net.darkhax.bookshelf.api.data.recipes.RecipeBase<C>
net.darkhax.bookshelf.api.data.recipes.RecipeBaseData<net.minecraft.world.Container>
net.darkhax.botanypots.data.recipes.crop.Crop
- All Implemented Interfaces:
net.minecraft.world.item.crafting.Recipe<net.minecraft.world.Container>
- Direct Known Subclasses:
BasicCrop
public abstract class Crop
extends net.darkhax.bookshelf.api.data.recipes.RecipeBaseData<net.minecraft.world.Container>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanGrowInSoil(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, Soil soil) Determines if the crop can grow in a given soil.abstract List<net.minecraft.world.item.ItemStack>generateDrops(Random rng, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Generates a new list of drops to spawn when the crop has been harvested.getCategories(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets a set of soil categories the crop can grow in.abstract List<DisplayState>getDisplayState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets the display state of the crop.abstract intgetGrowthTicks(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, Soil soil) Gets the amount of growth ticks required to grow the crop.abstract intgetLightLevel(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets the light level emitted by the crop when placed in a pot.net.minecraft.world.item.crafting.RecipeType<?>getType()abstract booleanmatchesLookup(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, net.minecraft.world.item.ItemStack placedStack) Tests if the crop matches the provided placement context.voidonGrowthTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, Soil soil) A hook that is invoked when the crop is being grown in a soil using the botany pot.voidonTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) A hook that is invoked when a botany pot using the crop is ticked.Methods inherited from class net.darkhax.bookshelf.api.data.recipes.RecipeBaseData
assemble, canCraftInDimensions, getResultItem, matchesMethods inherited from class net.darkhax.bookshelf.api.data.recipes.RecipeBase
getIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.item.crafting.Recipe
getGroup, getIngredients, getRemainingItems, getSerializer, getToastSymbol, isIncomplete, isSpecial, showNotification
-
Constructor Details
-
Crop
public Crop(net.minecraft.resources.ResourceLocation id)
-
-
Method Details
-
matchesLookup
public abstract boolean matchesLookup(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, net.minecraft.world.item.ItemStack placedStack) Tests if the crop matches the provided placement context. This is used when looking up crops from their ItemStack and determines which soil they represent.- Parameters:
level- The current world level that the crop is in.pos- The position of the pot.pot- The pot being used.placedStack- The ItemStack being placed.- Returns:
- Whether the crop matches the lookup context or not.
-
getGrowthTicks
public abstract int getGrowthTicks(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, @Nullable Soil soil) Gets the amount of growth ticks required to grow the crop.The soil parameter may be null in some circumstances. This indicates that the soil is not available in the current context, such as generating tooltip information.
This code is not responsible for applying the growth modifier of the soil. This is handled externally. Implementations of this method should not factor this in themselves.
- Parameters:
level- The current world level that the crop is in.pos- The position that the pot is at.pot- The pot growing the crop.soil- The soil that the crop is growing in.- Returns:
- The amount of growth ticks required to grow the crop.
-
getLightLevel
public abstract int getLightLevel(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets the light level emitted by the crop when placed in a pot.- Parameters:
level- The current world level that the crop is in.pos- The position that the pot is at.pot- The pot growing the crop.- Returns:
- The light level for the crop within the pot. This should be a value between 0 and 15.
-
canGrowInSoil
public abstract boolean canGrowInSoil(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, Soil soil) Determines if the crop can grow in a given soil.- Parameters:
level- The current world level that the crop is in.pos- The position of the pot.pot- The pot growing the crop.soil- The soil the crop is being grown in.- Returns:
- Whether the crop can grow in the soil.
-
getCategories
public abstract Set<String> getCategories(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets a set of soil categories the crop can grow in.- Parameters:
level- The current world level that the crop is in.pos- The position of the pot.pot- The pot growing the crop.- Returns:
- A set of soil categories that the crop can grow in.
-
getDisplayState
public abstract List<DisplayState> getDisplayState(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Gets the display state of the crop. This will be used to render the crop in the pot.- Parameters:
level- The current world level that the pot is in.pos- The position that the pot is at.pot- The pot growing the crop.- Returns:
- A display state to render inside the pot.
-
generateDrops
public abstract List<net.minecraft.world.item.ItemStack> generateDrops(Random rng, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) Generates a new list of drops to spawn when the crop has been harvested.- Parameters:
level- The current world level that the pot is in.pos- The position of the pot.pot- The pot growing the crop.- Returns:
- A list of drops to spawn when the crop is harvested.
-
onTick
public void onTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot) A hook that is invoked when a botany pot using the crop is ticked. This is invoked every tick, regardless of if the crop can grow.- Parameters:
level- The current world level that the pot is in.pos- The position of the pot.pot- The pot growing the crop.
-
onGrowthTick
public void onGrowthTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, BlockEntityBotanyPot pot, Soil soil) A hook that is invoked when the crop is being grown in a soil using the botany pot.- Parameters:
level- The current world level that the pot is in.pos- The position of the pot.pot- The pot growing the crop.soil- The soil that the crop is growing in.
-
getType
public net.minecraft.world.item.crafting.RecipeType<?> getType()
-