Class Crop
java.lang.Object
net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe
net.darkhax.botanypots.common.api.data.recipes.crop.Crop
- All Implemented Interfaces:
net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
- Direct Known Subclasses:
BasicCrop
Represents a type of crop that can grow in the botany pot.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<Crop>> static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<Map<net.minecraft.resources.ResourceLocation, net.minecraft.world.item.crafting.RecipeHolder<Crop>>> Fields inherited from interface net.minecraft.world.item.crafting.Recipe
CODEC, STREAM_CODEC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanHarvest(BotanyPotContext context, net.minecraft.world.level.Level level) Checks if the crop can be harvested.floatgetBaseYield(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the base chance that the crop will drop items when harvested.static @Nullable net.minecraft.world.item.crafting.RecipeHolder<Crop> getCrop(net.minecraft.world.level.Level level, BotanyPotContext context, net.minecraft.world.item.ItemStack stack) Gets the crop that best represents an item.getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the display states that should be rendered for the crop.intgetLightLevelEmitted(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the light level emitted by the crop.abstract intgetRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level) The amount of ticks required for the crop to grow under normal circumstance.@NotNull net.minecraft.world.item.crafting.RecipeType<?> getType()floatgetYieldScale(BotanyPotContext context, net.minecraft.world.level.Level level) Determines how much drop chance modifiers from other sources affect the base drop chance of the crop.abstract booleanisGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level) Checks if the crop can still grow under the current circumstances.voidonGrowthTick(BotanyPotContext context, net.minecraft.world.level.Level level) Invoked every tick while the crop is in a pot and the growth of the crop is sustained.abstract voidonHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops) Handles the harvesting logic for the crop.voidonTick(BotanyPotContext context, net.minecraft.world.level.Level level) Invoked every tick while the crop is in a pot.Methods inherited from class net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe
assemble, canCraftInDimensions, couldMatch, getResultItem, hoverTooltip, isSpecial, recipeCodec, recipeStream, showNotificationMethods 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, matches
-
Field Details
-
TYPE
-
RECIPES
-
CACHE
public static final net.darkhax.bookshelf.common.api.function.SidedReloadableCache<RecipeCache<Crop>> CACHE
-
-
Constructor Details
-
Crop
public Crop()
-
-
Method Details
-
onHarvest
public abstract void onHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops) Handles the harvesting logic for the crop. This is invoked when the crop is harvested by a player or through some automatic action like a hopping botany pot.- Parameters:
context- Additional context about the pot that is growing the crop and how the crop was harvested.level- The world in which the crop was harvested.drops- Collects items that were dropped as a result of harvesting the crop. For example, this may drop the items into the world or insert them into the pots inventory depending on how the crop was harvested.
-
getDisplayState
public abstract List<Display> getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the display states that should be rendered for the crop. When multiple displays are returned they will be rendered in bottom up order. For example if the crop is a 2 block tall multi-block you could return the lower block as the first display and the top block as the second display.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.- Returns:
- A list of display states to render for the crop.
-
getRequiredGrowthTicks
public abstract int getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level) The amount of ticks required for the crop to grow under normal circumstance. The result should not include fertilizer, soil growth modifiers, or any other modifier that is not inherent to the crop.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.- Returns:
- The base amount of ticks required to grow the crop.
-
isGrowthSustained
public abstract boolean isGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level) Checks if the crop can still grow under the current circumstances. This will be used to revalidate if the crop can continue to grow in the pot or if it is invalid. Crops that have reached max age should still have their growth sustained.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.- Returns:
- If the crop can still grow under the current circumstances.
-
getLightLevelEmitted
Gets the light level emitted by the crop.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.- Returns:
- The light level emitted by the crop.
-
getBaseYield
Gets the base chance that the crop will drop items when harvested.- Parameters:
context- Context for how the crop is being grown.level- The world the crop is growing in.- Returns:
- The base chance that the crop drops items when harvested.
-
getYieldScale
Determines how much drop chance modifiers from other sources affect the base drop chance of the crop.- Parameters:
context- Context for how the crop is being grown.level- The world the crop is growing in.- Returns:
- The scale to apply to drop modifiers.
-
onTick
Invoked every tick while the crop is in a pot. This can be used for adding tick based effects to your crop, like a random chance to spawn a mob, mutate, or wither.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.
-
onGrowthTick
Invoked every tick while the crop is in a pot and the growth of the crop is sustained.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.
-
canHarvest
Checks if the crop can be harvested. This can be used to add harvest conditions that are unrelated to the standard growth logic, like only allowing the crop to be harvested at night.- Parameters:
context- Additional context about the pot that is growing the crop.level- The world the crop is growing in.- Returns:
- If the crop can be harvested.
-
getType
@NotNull public @NotNull net.minecraft.world.item.crafting.RecipeType<?> getType() -
getCrop
@Nullable public static @Nullable net.minecraft.world.item.crafting.RecipeHolder<Crop> getCrop(net.minecraft.world.level.Level level, BotanyPotContext context, net.minecraft.world.item.ItemStack stack) Gets the crop that best represents an item.- Parameters:
level- The current game level.context- The current game context.stack- The item to lookup.- Returns:
- The crop that best represents the item.
-