public class ExampleBlock extends Block { public ExampleBlock(Settings settings) { super(settings); } // For versions below 1.20.5, the parameters should be "BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit" @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) { if (!world.isClient) { player.sendMessage(Text.literal("Hello, world!"), false); } return ActionResult.SUCCESS; } }