Package net.fabricmc.fabric.api.registry
Class TillableBlockRegistry
java.lang.Object
net.fabricmc.fabric.api.registry.TillableBlockRegistry
A registry for hoe tilling interactions. A vanilla example is turning dirt to dirt paths.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidregister(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, Consumer<net.minecraft.item.ItemUsageContext> tillingAction)Registers a tilling interaction.static voidregister(net.minecraft.block.Block input, Predicate<net.minecraft.item.ItemUsageContext> usagePredicate, net.minecraft.block.BlockState tilled)Registers a simple tilling interaction.static voidregister(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.
-
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 theseHoeItemmethods:- 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 tilledusagePredicate- a predicate that filters if the block can be tilledtillingAction- an action that is executed if the predicate returnstrue
- usage predicate for farmland-like behavior:
-
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 tilledusagePredicate- a predicate that filters if the block can be tilledtilled- 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 tilledusagePredicate- a predicate that filters if the block can be tilledtilled- the tilled result block statedroppedItem- an item that is dropped when the input block is tilled
-