Interface IWrenchRegistry
- All Known Implementing Classes:
ModdedWrenchUtils
public interface IWrenchRegistry
Some utilities for interacting with third-party wrench behaviours.
Get an instance of this with
PneumaticRegistry.IPneumaticCraftInterface.getWrenchRegistry()-
Method Summary
Modifier and TypeMethodDescriptionvoidaddModdedWrenchBehaviour(String modid, BiFunction<net.minecraft.world.item.context.UseOnContext, net.minecraft.world.level.block.state.BlockState, net.minecraft.world.InteractionResult> behaviourPre, BiConsumer<net.minecraft.world.item.context.UseOnContext, net.minecraft.world.level.block.state.BlockState> behaviourPost) Register a third-party behaviour for when blocks from another mod are wrenched with the Pneumatic Wrench.booleanisModdedWrench(net.minecraft.world.item.ItemStack stack) Check if the given item is considered as a modded wrench (so does not include the Pneumatic Wrench).booleanisWrench(net.minecraft.world.item.ItemStack stack) Check if the given item is any known wrench item, including the Pneumatic Wrench.voidregisterWrench(net.minecraft.world.item.Item wrench) Register the given item as a wrench, as far as PneumaticCraft is concerned.
-
Method Details
-
isModdedWrench
boolean isModdedWrench(@Nonnull net.minecraft.world.item.ItemStack stack) Check if the given item is considered as a modded wrench (so does not include the Pneumatic Wrench). PneumaticCraft is by default aware of wrenches from several well-known mods. Note that items added to theforge:tools/wrenchitem tag will also be considered as modded wrenches.- Parameters:
stack- the item to check- Returns:
- true if it's a modded wrench, false otherwise
-
isWrench
boolean isWrench(@Nonnull net.minecraft.world.item.ItemStack stack) Check if the given item is any known wrench item, including the Pneumatic Wrench.- Parameters:
stack- the item to check- Returns:
- true if it's a wrench, false otherwise
-
registerWrench
void registerWrench(net.minecraft.world.item.Item wrench) Register the given item as a wrench, as far as PneumaticCraft is concerned. Note that the preferred way to do this is to add the item to theforge:tools/wrenchitem tag.- Parameters:
wrench- a wrench item
-
addModdedWrenchBehaviour
void addModdedWrenchBehaviour(String modid, BiFunction<net.minecraft.world.item.context.UseOnContext, net.minecraft.world.level.block.state.BlockState, net.minecraft.world.InteractionResult> behaviourPre, BiConsumer<net.minecraft.world.item.context.UseOnContext, net.minecraft.world.level.block.state.BlockState> behaviourPost) Register a third-party behaviour for when blocks from another mod are wrenched with the Pneumatic Wrench.The return value from
behaviourPreis also returned byIForgeItem.onItemUseFirst(ItemStack, UseOnContext)when the Pneumatic Wrench is used. Any return value other than PASS will suppress the default Pneumatic Wrench behaviour (including air usage); returning CONSUME will also suppress the Pneumatic Wrench's sound effect.The code in
behaviourPostwill only be run ifbehaviourPrereturned PASS (i.e. did not suppress the default Pneumatic Wrench behaviour).- Parameters:
modid- the mod whose blocks to register the behaviour for; must exactly match the mod's namespacebehaviourPre- code to run when blocks from the mod are about to be wrenched with the Pneumatic WrenchbehaviourPost- code to run when blocks from the mod have just been wrenched with the Pneumatic Wrench
-