Class TillableBlockRegistry

java.lang.Object
net.fabricmc.fabric.api.registry.TillableBlockRegistry

public final class TillableBlockRegistry extends Object
A registry for hoe tilling interactions. A vanilla example is turning dirt to dirt paths.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, Consumer<net.minecraft.item.ItemUsageContext> tillingAction)
    Registers a tilling interaction.
    static void
    register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, net.minecraft.block.BlockState tilled)
    Registers a simple tilling interaction.
    static void
    register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, net.minecraft.block.BlockState tilled, net.minecraft.item.ItemConvertible droppedItem)
    Registers a simple tilling interaction that also drops an item.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • register

      public static void register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, Consumer<net.minecraft.item.ItemUsageContext> tillingAction)
      Registers a tilling interaction.

      Tilling interactions are a two-step process. First, a usage predicate is run that decides whether to till a block. If the predicate returns true, an action is executed. Default instances of these can be created with these HoeItem methods:

      • usage predicate for farmland-like behavior: HoeItem.canTillFarmland(ItemUsageContext)
      • simple action: HoeItem.createTillAction(BlockState) (BlockState)}
      • simple action that also drops an item: HoeItem.createTillAndDropAction(BlockState, ItemConvertible)
      Parameters:
      input - the input block that can be tilled
      usagePredicate - a predicate that filters if the block can be tilled
      tillingAction - an action that is executed if the predicate returns true
    • register

      public static void register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, net.minecraft.block.BlockState tilled)
      Registers a simple tilling interaction.
      Parameters:
      input - the input block that can be tilled
      usagePredicate - a predicate that filters if the block can be tilled
      tilled - the tilled result block state
    • register

      public static void register(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, net.minecraft.block.BlockState tilled, net.minecraft.item.ItemConvertible droppedItem)
      Registers a simple tilling interaction that also drops an item.
      Parameters:
      input - the input block that can be tilled
      usagePredicate - a predicate that filters if the block can be tilled
      tilled - the tilled result block state
      droppedItem - an item that is dropped when the input block is tilled