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.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, Consumer<net.minecraft.world.item.context.UseOnContext> tillingAction) Registers a tilling interaction.static voidregister(net.minecraft.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, net.minecraft.world.level.block.state.BlockState tilled) Registers a simple tilling interaction.static voidregister(net.minecraft.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, net.minecraft.world.level.block.state.BlockState tilled, net.minecraft.world.level.ItemLike droppedItem) Registers a simple tilling interaction that also drops an item.
-
Method Details
-
register
public static void register(net.minecraft.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, Consumer<net.minecraft.world.item.context.UseOnContext> 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.onlyIfAirAbove(UseOnContext) - simple action:
HoeItem.changeIntoState(BlockState)(BlockState)} - simple action that also drops an item:
HoeItem.changeIntoStateAndDropItem(BlockState, ItemLike)
- 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.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, net.minecraft.world.level.block.state.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.world.level.block.Block input, Predicate<net.minecraft.world.item.context.UseOnContext> usagePredicate, net.minecraft.world.level.block.state.BlockState tilled, net.minecraft.world.level.ItemLike 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
-