Class BasicCrop
java.lang.Object
net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe
net.darkhax.botanypots.common.api.data.recipes.crop.Crop
net.darkhax.botanypots.common.impl.data.recipe.crop.BasicCrop
- All Implemented Interfaces:
CacheableRecipe,net.minecraft.world.item.crafting.Recipe<BotanyPotContext>
- Direct Known Subclasses:
BlockDerivedCrop
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<BasicCrop> static final net.minecraft.world.item.crafting.Ingredientstatic final net.minecraft.world.item.crafting.RecipeSerializer<BasicCrop> static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, BasicCrop> Fields inherited from class net.darkhax.botanypots.common.api.data.recipes.crop.Crop
CACHE, RECIPES, TYPEFields inherited from interface net.minecraft.world.item.crafting.Recipe
STREAM_CODEC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if recipe can be cached based on the deserialized contents of the recipe.booleancouldMatch(net.minecraft.world.item.ItemStack candidate, BotanyPotContext context, net.minecraft.world.level.Level level) Tests if the recipe is valid for the current context.floatgetBaseYield(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the base chance that the crop will drop items when harvested.getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level) Gets the display states that should be rendered for the crop.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.RecipeSerializer<?> 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.voidhoverTooltip(net.minecraft.world.item.ItemStack stack, BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.network.chat.Component> tooltipLines) Populates a tooltip when the item is hovered in a botany pot.booleanisCacheKey(net.minecraft.world.item.ItemStack stack) Determines if a given item would be a valid cache key for this recipe.booleanisGrowthSustained(BotanyPotContext context, net.minecraft.world.level.Level level) Checks if the crop can still grow under the current circumstances.booleanisValidSoil(net.minecraft.world.item.ItemStack stack) booleanmatches(@NotNull BotanyPotContext input, @NotNull net.minecraft.world.level.Level level) voidonHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops) Handles the harvesting logic for the crop.Methods inherited from class net.darkhax.botanypots.common.api.data.recipes.crop.Crop
canHarvest, getCrop, getLightLevelEmitted, getType, onGrowthTick, onTickMethods inherited from class net.darkhax.botanypots.common.api.data.recipes.BotanyPotRecipe
assemble, canCraftInDimensions, getResultItem, 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, getToastSymbol, isIncomplete
-
Field Details
-
DIRT
public static final net.minecraft.world.item.crafting.Ingredient DIRT -
CODEC
-
STREAM
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,BasicCrop> STREAM -
SERIALIZER
-
-
Constructor Details
-
BasicCrop
-
-
Method Details
-
getBasicProperties
-
matches
public boolean matches(@NotNull @NotNull BotanyPotContext input, @NotNull @NotNull net.minecraft.world.level.Level level) - Specified by:
matchesin interfacenet.minecraft.world.item.crafting.Recipe<BotanyPotContext>
-
couldMatch
public boolean couldMatch(net.minecraft.world.item.ItemStack candidate, BotanyPotContext context, net.minecraft.world.level.Level level) Description copied from class:BotanyPotRecipeTests if the recipe is valid for the current context.- Specified by:
couldMatchin classBotanyPotRecipe- Parameters:
candidate- The item to test.context- The current context.level- The current game level.- Returns:
- If the recipe is valid.
-
onHarvest
public void onHarvest(BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.world.item.ItemStack> drops) Description copied from class:CropHandles 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.- Specified by:
onHarvestin classCrop- 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 List<Display> getDisplayState(BotanyPotContext context, net.minecraft.world.level.Level level) Description copied from class:CropGets 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.- Specified by:
getDisplayStatein classCrop- 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
Description copied from class:CropThe 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.- Specified by:
getRequiredGrowthTicksin classCrop- 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
Description copied from class:CropChecks 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.- Specified by:
isGrowthSustainedin classCrop- 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.
-
getBaseYield
Description copied from class:CropGets the base chance that the crop will drop items when harvested.- Overrides:
getBaseYieldin classCrop- 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
Description copied from class:CropDetermines how much drop chance modifiers from other sources affect the base drop chance of the crop.- Overrides:
getYieldScalein classCrop- 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.
-
canBeCached
public boolean canBeCached()Description copied from interface:CacheableRecipeDetermines if recipe can be cached based on the deserialized contents of the recipe. For example, imagine a recipe with an optional list of non-cacheable conditions. If this list is not present or empty, the recipe could be cached when it otherwise could not.- Specified by:
canBeCachedin interfaceCacheableRecipe- Returns:
- If the recipe can be cached.
-
isCacheKey
public boolean isCacheKey(net.minecraft.world.item.ItemStack stack) Description copied from interface:CacheableRecipeDetermines if a given item would be a valid cache key for this recipe. Recipes can have more than one valid key.Implementations should only check intrinsic properties of the stack like the item id, tags, and the type of the item. Properties like data components should not be checked as these are not intrinsic to the item. An ItemStack is only provided in this context because it is needed to test Ingredient.
- Specified by:
isCacheKeyin interfaceCacheableRecipe- Parameters:
stack- The item to test.- Returns:
- If the item is a valid cache key for this recipe.
-
getSerializer
@NotNull public @NotNull net.minecraft.world.item.crafting.RecipeSerializer<?> getSerializer()- Specified by:
getSerializerin interfacenet.minecraft.world.item.crafting.Recipe<BotanyPotContext>
-
hoverTooltip
public void hoverTooltip(net.minecraft.world.item.ItemStack stack, BotanyPotContext context, net.minecraft.world.level.Level level, Consumer<net.minecraft.network.chat.Component> tooltipLines) Description copied from class:BotanyPotRecipePopulates a tooltip when the item is hovered in a botany pot.- Overrides:
hoverTooltipin classBotanyPotRecipe- Parameters:
stack- The ItemStack being hovered.context- The context of the current situation.level- The current game level.tooltipLines- The list of tooltips being displayed.
-
isValidSoil
public boolean isValidSoil(net.minecraft.world.item.ItemStack stack)
-