Interface SpecialPlantable


public interface SpecialPlantable
Intended for mods to help mark if a modded item allows for placing modded plants of any kind or size. Also allows Villagers to properly plant items with this interface on and villagerCanPlantItem returning true.

People trying to plant modded items should check if item implements this interface. Then check for true from canPlacePlantAtPosition first before calling spawnPlantAtPosition. Implementers of this interface would ideally call canSurvive on their plant block in canPlacePlantAtPosition.

(Note: Vanilla plantable items are BlockItem where you can get their states directly and call canSurvive)
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canPlacePlantAtPosition(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction direction)
    Checks location if this item can spawn a plant with the given direction attachment point.
    void
    spawnPlantAtPosition(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction direction)
    Spawns the plant with the given direction attachment point at location.
    default boolean
    villagerCanPlantItem(net.minecraft.world.entity.npc.Villager villager)
    Whether Villagers can pick up this item and plant it down on any block that extends FarmBlock.
  • Method Details

    • canPlacePlantAtPosition

      boolean canPlacePlantAtPosition(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Direction direction)
      Checks location if this item can spawn a plant with the given direction attachment point.
      Returns:
      If plant can spawn
    • spawnPlantAtPosition

      void spawnPlantAtPosition(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Direction direction)
      Spawns the plant with the given direction attachment point at location. Ideally called after canPlacePlantAtPosition returns true.
    • villagerCanPlantItem

      default boolean villagerCanPlantItem(net.minecraft.world.entity.npc.Villager villager)
      Whether Villagers can pick up this item and plant it down on any block that extends FarmBlock.