Search in sources :

Example 6 with IPlacementHelper

use of com.simibubi.create.foundation.utility.placement.IPlacementHelper in project Create by Creators-of-Create.

the class SailBlock 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 placementHelper.getOffset(player, world, state, pos, ray).placeInWorld(world, (BlockItem) heldItem.getItem(), player, hand, ray);
    if (heldItem.getItem() instanceof ShearsItem) {
        if (!world.isClientSide)
            applyDye(state, world, pos, null);
        return InteractionResult.SUCCESS;
    }
    if (frame)
        return InteractionResult.PASS;
    DyeColor color = DyeColor.getColor(heldItem);
    if (color != null) {
        if (!world.isClientSide)
            applyDye(state, world, pos, color);
        return InteractionResult.SUCCESS;
    }
    return InteractionResult.PASS;
}
Also used : ShearsItem(net.minecraft.world.item.ShearsItem) ItemStack(net.minecraft.world.item.ItemStack) DyeColor(net.minecraft.world.item.DyeColor) BlockItem(net.minecraft.world.item.BlockItem) IPlacementHelper(com.simibubi.create.foundation.utility.placement.IPlacementHelper)

Aggregations

IPlacementHelper (com.simibubi.create.foundation.utility.placement.IPlacementHelper)6 BlockItem (net.minecraft.world.item.BlockItem)5 ItemStack (net.minecraft.world.item.ItemStack)5 EncasedShaftBlock (com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock)1 BlockPos (net.minecraft.core.BlockPos)1 Player (net.minecraft.world.entity.player.Player)1 DyeColor (net.minecraft.world.item.DyeColor)1 ShearsItem (net.minecraft.world.item.ShearsItem)1 Level (net.minecraft.world.level.Level)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 BlockHitResult (net.minecraft.world.phys.BlockHitResult)1