use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.
the class GantryShaftBlock method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
ItemStack heldItem = player.getItemInHand(hand);
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
if (!placementHelper.matchesItem(heldItem))
return InteractionResult.PASS;
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, ((BlockItem) heldItem.getItem()), player, hand, ray);
}
use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.
the class SpeedControllerBlock method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
ItemStack heldItem = player.getItemInHand(hand);
IPlacementHelper helper = PlacementHelpers.get(placementHelperId);
if (helper.matchesItem(heldItem))
return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
return InteractionResult.PASS;
}
use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.
the class ShaftBlock method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
if (player.isShiftKeyDown() || !player.mayBuild())
return InteractionResult.PASS;
ItemStack heldItem = player.getItemInHand(hand);
for (EncasedShaftBlock encasedShaft : new EncasedShaftBlock[] { AllBlocks.ANDESITE_ENCASED_SHAFT.get(), AllBlocks.BRASS_ENCASED_SHAFT.get() }) {
if (!encasedShaft.getCasing().isIn(heldItem))
continue;
if (world.isClientSide)
return InteractionResult.SUCCESS;
AllTriggers.triggerFor(AllTriggers.CASING_SHAFT, player);
KineticTileEntity.switchToBlockState(world, pos, encasedShaft.defaultBlockState().setValue(AXIS, state.getValue(AXIS)));
return InteractionResult.SUCCESS;
}
IPlacementHelper helper = PlacementHelpers.get(placementHelperId);
if (helper.matchesItem(heldItem))
return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
return InteractionResult.PASS;
}
use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.
the class PistonExtensionPoleBlock method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
ItemStack heldItem = player.getItemInHand(hand);
IPlacementHelper placementHelper = PlacementHelpers.get(placementHelperId);
if (placementHelper.matchesItem(heldItem) && !player.isShiftKeyDown())
return placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
return InteractionResult.PASS;
}
use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.
the class CogwheelBlockItem method onItemUseFirst.
@Override
public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) {
Level world = context.getLevel();
BlockPos pos = context.getClickedPos();
BlockState state = world.getBlockState(pos);
IPlacementHelper helper = PlacementHelpers.get(placementHelperId);
Player player = context.getPlayer();
BlockHitResult ray = new BlockHitResult(context.getClickLocation(), context.getClickedFace(), pos, true);
if (helper.matchesState(state) && player != null && !player.isShiftKeyDown()) {
return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, this, player, context.getHand(), ray);
}
if (integratedCogHelperId != -1) {
helper = PlacementHelpers.get(integratedCogHelperId);
if (helper.matchesState(state) && player != null && !player.isShiftKeyDown()) {
return helper.getOffset(player, world, state, pos, ray).placeInWorld(world, this, player, context.getHand(), ray);
}
}
return super.onItemUseFirst(stack, context);
}
Aggregations