Interface FarmingRegistry


public interface FarmingRegistry
What takes part in farming, and how: the FarmingBehaviour attached to each block type, and what items do to the land.

Whatever a plugin declares here is in effect until it is disabled, or until it takes it back with detachAll(Plugin). The latest declaration wins, and the previous one is in effect again once the latest is taken back, so that a plugin can override a built-in plant and give it back.

Since:
0.1.0
See Also:
  • Method Details

    • attach

      void attach(TypedKey<BlockType> block, FarmingBehaviour behaviour, Plugin owner)
      Attaches a behaviour to a block type, in place of the one in effect.
      Parameters:
      block - the block type
      behaviour - its farming behaviour
      owner - the owner of the attachment, usually the Plugin instance; it is released by detachAll(Plugin)
      Since:
      0.1.0
    • detach

      boolean detach(TypedKey<BlockType> block, Plugin owner)
      Detaches the behaviours an owner attached to a block type.
      Parameters:
      block - the block type
      owner - the owner given when attaching
      Returns:
      true if at least one behaviour was detached
      Since:
      0.1.0
    • detachAll

      void detachAll(Plugin owner)
      Takes back everything an owner declared: the behaviours it attached, and its seeds, fertilizers, hoes and tillable soils.
      Parameters:
      owner - the owner given when declaring
      Since:
      0.1.0
    • behaviour

      Returns the behaviour in effect for a block type, empty for a block taking no part in farming.
      Parameters:
      block - the block type
      Returns:
      the behaviour in effect for a block type, empty for a block taking no part in farming
      Since:
      0.1.0
    • behaviour

      default Optional<FarmingBehaviour> behaviour(BlockData data)
      Returns the behaviour in effect for the type of a state, empty for a block taking no part in farming.
      Parameters:
      data - the state
      Returns:
      the behaviour in effect for the type of a state, empty for a block taking no part in farming
      Since:
      0.1.0
    • blocks

      Set<TypedKey<BlockType>> blocks()
      Returns an immutable snapshot of the block types that have a behaviour.
      Returns:
      an immutable snapshot of the block types that have a behaviour
      Since:
      0.1.0
    • seed

      void seed(TypedKey<Item> item, TypedKey<BlockType> plant, Plugin owner)
      Declares an item as the seed of a plant: using it on a block plants the default state of the plant against the clicked face, where the plant can stand, and uses one item up.
      Parameters:
      item - the item
      plant - the block type it plants
      owner - the owner of the declaration
      Since:
      0.1.0
    • plant

      Returns the block type an item plants, empty for an item that is not a seed.
      Parameters:
      item - the item
      Returns:
      the block type an item plants, empty for an item that is not a seed
      Since:
      0.1.0
    • fertilizer

      void fertilizer(TypedKey<Item> item, Plugin owner)
      Declares an item as a fertilizer: using it on a block that takes fertilizer feeds the block and uses one item up.
      Parameters:
      item - the item
      owner - the owner of the declaration
      Since:
      0.1.0
    • isFertilizer

      boolean isFertilizer(TypedKey<Item> item)
      Returns true if an item is a fertilizer.
      Parameters:
      item - the item
      Returns:
      true if an item is a fertilizer
      Since:
      0.1.0
    • hoe

      void hoe(TypedKey<Item> item, Plugin owner)
      Declares an item as a hoe: using it on tillable soil tills it and wears the item. The items of the minecraft:hoes tag are hoes without being declared.
      Parameters:
      item - the item
      owner - the owner of the declaration
      Since:
      0.1.0
    • isHoe

      boolean isHoe(TypedKey<Item> item)
      Returns true if an item is a hoe.
      Parameters:
      item - the item
      Returns:
      true if an item is a hoe
      Since:
      0.1.0
    • tillable

      void tillable(TypedKey<BlockType> soil, Tillage tillage, Plugin owner)
      Declares what a hoe does to a block type.
      Parameters:
      soil - the block type a hoe is used on
      tillage - what it turns into, and what comes out of it
      owner - the owner of the declaration
      Since:
      0.1.0
    • tillage

      Returns what a hoe does to a block type, empty for a block a hoe does nothing to.
      Parameters:
      soil - the block type a hoe is used on
      Returns:
      what a hoe does to a block type, empty for a block a hoe does nothing to
      Since:
      0.1.0