use of com.simibubi.create.content.contraptions.wrench.IWrenchable in project Materialis by RCXcrafter.
the class CreateWrenchingModifier method beforeBlockUse.
@Override
public ActionResultType beforeBlockUse(IModifierToolStack tool, int level, ItemUseContext context) {
if (enabled && !tool.isBroken() && context.getPlayer() != null) {
World world = context.getLevel();
BlockPos pos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
Block block = state.getBlock();
if (!(block instanceof IWrenchable)) {
if (context.getPlayer().isSecondaryUseActive() && AllTags.AllBlockTags.WRENCH_PICKUP.matches(state)) {
ToolDamageUtil.damage(tool, 1, context.getPlayer(), context.getItemInHand());
return onItemUseOnOther(world, pos, state, context);
}
return ActionResultType.PASS;
}
IWrenchable actor = (IWrenchable) block;
ToolDamageUtil.damage(tool, 1, context.getPlayer(), context.getItemInHand());
if (context.getPlayer().isSecondaryUseActive())
return actor.onSneakWrenched(state, context);
return actor.onWrenched(state, context);
}
return ActionResultType.PASS;
}
Aggregations