package ru.bclib.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.BlockHitResult; public class EndBlockStripableLogLog extends EndPillarBlock { private final Block striped; public EndBlockStripableLogLog(MaterialColor color, Block striped) { super(FabricBlockSettings.copyOf(striped).materialColor(color)); this.striped = striped; } @Override public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) { world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F); if (!world.isClientSide) { world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11); if (player != null && !player.isCreative()) { player.getMainHandItem().hurt(1, world.random, (ServerPlayer) player); } } return InteractionResult.SUCCESS; } return InteractionResult.FAIL; } }